Skip to content

Commit

Permalink
feat: add Torch plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
robingenz committed Sep 12, 2024
1 parent 232201b commit 9930ef7
Show file tree
Hide file tree
Showing 16 changed files with 179 additions and 2 deletions.
1 change: 1 addition & 0 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
implementation project(':capawesome-capacitor-photo-editor')
implementation project(':capawesome-capacitor-posthog')
implementation project(':capawesome-capacitor-screen-orientation')
implementation project(':capawesome-capacitor-torch')

}

Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/assets/capacitor.plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,9 @@
{
"pkg": "@capawesome/capacitor-screen-orientation",
"classpath": "io.capawesome.capacitorjs.plugins.screenorientation.ScreenOrientationPlugin"
},
{
"pkg": "@capawesome/capacitor-torch",
"classpath": "io.capawesome.capacitorjs.plugins.torch.TorchPlugin"
}
]
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ project(':capawesome-capacitor-posthog').projectDir = new File('../node_modules/

include ':capawesome-capacitor-screen-orientation'
project(':capawesome-capacitor-screen-orientation').projectDir = new File('../node_modules/@capawesome/capacitor-screen-orientation/android')

include ':capawesome-capacitor-torch'
project(':capawesome-capacitor-torch').projectDir = new File('../node_modules/@capawesome/capacitor-torch/android')
3 changes: 2 additions & 1 deletion ios/App/App/capacitor.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"ManagedConfigurationsPlugin",
"PhotoEditorPlugin",
"PosthogPlugin",
"ScreenOrientationPlugin"
"ScreenOrientationPlugin",
"TorchPlugin"
]
}
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def capacitor_pods
pod 'CapawesomeCapacitorPhotoEditor', :path => '../../node_modules/@capawesome/capacitor-photo-editor'
pod 'CapawesomeCapacitorPosthog', :path => '../../node_modules/@capawesome/capacitor-posthog'
pod 'CapawesomeCapacitorScreenOrientation', :path => '../../node_modules/@capawesome/capacitor-screen-orientation'
pod 'CapawesomeCapacitorTorch', :path => '../../node_modules/@capawesome/capacitor-torch'
end

target 'App' do
Expand Down
8 changes: 7 additions & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ PODS:
- PostHog (= 3.8.2)
- CapawesomeCapacitorScreenOrientation (6.0.1):
- Capacitor
- CapawesomeCapacitorTorch (5.0.0):
- Capacitor
- CapawesomeTeamCapacitorBluetoothLowEnergy (6.0.0):
- Capacitor
- CapawesomeTeamCapacitorDatetimePicker (6.0.0):
Expand Down Expand Up @@ -88,6 +90,7 @@ DEPENDENCIES:
- "CapawesomeCapacitorPhotoEditor (from `../../node_modules/@capawesome/capacitor-photo-editor`)"
- "CapawesomeCapacitorPosthog (from `../../node_modules/@capawesome/capacitor-posthog`)"
- "CapawesomeCapacitorScreenOrientation (from `../../node_modules/@capawesome/capacitor-screen-orientation`)"
- "CapawesomeCapacitorTorch (from `../../node_modules/@capawesome/capacitor-torch`)"
- "CapawesomeTeamCapacitorBluetoothLowEnergy (from `../../node_modules/@capawesome-team/capacitor-bluetooth-low-energy`)"
- "CapawesomeTeamCapacitorDatetimePicker (from `../../node_modules/@capawesome-team/capacitor-datetime-picker`)"
- "CapawesomeTeamCapacitorFileCompressor (from `../../node_modules/@capawesome-team/capacitor-file-compressor`)"
Expand Down Expand Up @@ -146,6 +149,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capawesome/capacitor-posthog"
CapawesomeCapacitorScreenOrientation:
:path: "../../node_modules/@capawesome/capacitor-screen-orientation"
CapawesomeCapacitorTorch:
:path: "../../node_modules/@capawesome/capacitor-torch"
CapawesomeTeamCapacitorBluetoothLowEnergy:
:path: "../../node_modules/@capawesome-team/capacitor-bluetooth-low-energy"
CapawesomeTeamCapacitorDatetimePicker:
Expand Down Expand Up @@ -184,6 +189,7 @@ SPEC CHECKSUMS:
CapawesomeCapacitorPhotoEditor: 231e03215f026e0c2eeb6de0910e095e4aa0c823
CapawesomeCapacitorPosthog: 84e91ce0c10ce2ffc98fe07a887377370eab7c26
CapawesomeCapacitorScreenOrientation: 9cc68ecd085fcea2e1755475a3ed60d85e604a6c
CapawesomeCapacitorTorch: 147301bf35352215d3b472c10f83e3a8bbe30677
CapawesomeTeamCapacitorBluetoothLowEnergy: 8a79dcc9f2edde2cf8304b4f628fa3260e12a5d4
CapawesomeTeamCapacitorDatetimePicker: 6dd2e7ae30c4b55afd48f19bfeb4578dcaa9263e
CapawesomeTeamCapacitorFileCompressor: be4a55e6476c4084ef370e84c224fc63db27f7a5
Expand All @@ -195,6 +201,6 @@ SPEC CHECKSUMS:
PostHog: c5e174a4c52c45a37bc3960ab103d21eb29b63d6
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef

PODFILE CHECKSUM: b8b66170f00243d5012b498430c2d9fb5995ebc1
PODFILE CHECKSUM: a8752795a6c6c530420d974700ec4950f815b7ba

COCOAPODS: 1.15.2
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@capawesome/capacitor-photo-editor": "6.0.0",
"@capawesome/capacitor-posthog": "https://pkg.pr.new/capawesome-team/capacitor-plugins/@capawesome/capacitor-posthog@dae64ba",
"@capawesome/capacitor-screen-orientation": "6.0.1",
"@capawesome/capacitor-torch": "https://pkg.pr.new/capawesome-team/capacitor-plugins/@capawesome/capacitor-torch@289",
"@ionic/angular": "7.3.4",
"posthog-js": "1.160.3",
"rxjs": "7.5.7",
Expand Down
5 changes: 5 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ const routes: Routes = [
m => m.TextToSpeechPageModule,
),
},
{
path: 'torch',
loadChildren: () =>
import('./modules/torch/torch.module').then(m => m.TorchPageModule),
},
{
path: 'wifi',
loadChildren: () =>
Expand Down
4 changes: 4 additions & 0 deletions src/app/modules/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ export class HomePage {
name: 'Text To Speech',
url: '/text-to-speech',
},
{
name: 'Torch',
url: '/torch',
},
{
name: 'Wifi',
url: '/wifi',
Expand Down
17 changes: 17 additions & 0 deletions src/app/modules/torch/torch-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { TorchPage } from './torch.page';

const routes: Routes = [
{
path: '',
component: TorchPage,
},
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class TorchPageRoutingModule {}
10 changes: 10 additions & 0 deletions src/app/modules/torch/torch.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { SharedModule } from '@app/shared';
import { TorchPageRoutingModule } from './torch-routing.module';
import { TorchPage } from './torch.page';

@NgModule({
imports: [SharedModule, TorchPageRoutingModule],
declarations: [TorchPage],
})
export class TorchPageModule {}
43 changes: 43 additions & 0 deletions src/app/modules/torch/torch.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="home"></ion-back-button>
</ion-buttons>
<ion-title>Torch</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<ion-card>
<ion-card-header>
<ion-card-title>About</ion-card-title>
</ion-card-header>
<ion-card-content>
⚡️ Capacitor plugin for switching the flashlight on and off.
</ion-card-content>
<ion-row class="ion-no-padding">
<ion-col>
<ion-button
fill="clear"
(click)="openOnGithub()"
class="ion-float-right"
>GitHub</ion-button
>
</ion-col>
</ion-row>
</ion-card>
<ion-card>
<ion-card-header>
<ion-card-title>Demo</ion-card-title>
</ion-card-header>
<ion-card-content>
<ion-button expand="block" (click)="enable()">Enable</ion-button>
<ion-button expand="block" (click)="disable()">Disable</ion-button>
<ion-button expand="block" (click)="isAvailable()"
>Is Available</ion-button
>
<ion-button expand="block" (click)="isEnabled()">Is Enabled</ion-button>
<ion-button expand="block" (click)="toggle()">Toggle</ion-button>
</ion-card-content>
</ion-card>
</ion-content>
Empty file.
24 changes: 24 additions & 0 deletions src/app/modules/torch/torch.page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { SharedTestingModule } from '@tests/modules';
import { TorchPage } from './torch.page';

describe('TorchPage', () => {
let component: TorchPage;
let fixture: ComponentFixture<TorchPage>;

beforeEach(async () => {
TestBed.configureTestingModule({
declarations: [TorchPage],
imports: [SharedTestingModule],
providers: [],
}).compileComponents();

fixture = TestBed.createComponent(TorchPage);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
38 changes: 38 additions & 0 deletions src/app/modules/torch/torch.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component } from '@angular/core';
import { Torch } from '@capawesome/capacitor-torch';

@Component({
selector: 'app-torch',
templateUrl: './torch.page.html',
styleUrls: ['./torch.page.scss'],
})
export class TorchPage {
private readonly GH_URL =
'https://github.com/capawesome-team/capacitor-plugins';

constructor() {}

public openOnGithub(): void {
window.open(this.GH_URL, '_blank');
}

public async enable(): Promise<void> {
await Torch.enable();
}

public async disable(): Promise<void> {
await Torch.disable();
}

public async isAvailable(): Promise<void> {
await Torch.isAvailable();
}

public async isEnabled(): Promise<void> {
await Torch.isEnabled();
}

public async toggle(): Promise<void> {
await Torch.toggle();
}
}

0 comments on commit 9930ef7

Please sign in to comment.