Skip to content

Commit

Permalink
Merge pull request #2495 from IDEMSInternational/feat/screen-orientation
Browse files Browse the repository at this point in the history
feat: screen_orientation action
  • Loading branch information
esmeetewinkel authored Oct 31, 2024
2 parents 6761ce1 + 0b958d3 commit dd4f459
Show file tree
Hide file tree
Showing 11 changed files with 85 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 @@ -19,6 +19,7 @@ dependencies {
implementation project(':capacitor-filesystem')
implementation project(':capacitor-local-notifications')
implementation project(':capacitor-push-notifications')
implementation project(':capacitor-screen-orientation')
implementation project(':capacitor-share')
implementation project(':capacitor-splash-screen')
implementation project(':capawesome-capacitor-app-update')
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 @@ -39,6 +39,10 @@
"pkg": "@capacitor/push-notifications",
"classpath": "com.capacitorjs.plugins.pushnotifications.PushNotificationsPlugin"
},
{
"pkg": "@capacitor/screen-orientation",
"classpath": "com.capacitorjs.plugins.screenorientation.ScreenOrientationPlugin"
},
{
"pkg": "@capacitor/share",
"classpath": "com.capacitorjs.plugins.share.SharePlugin"
Expand Down
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ project(':capacitor-local-notifications').projectDir = new File('../node_modules
include ':capacitor-push-notifications'
project(':capacitor-push-notifications').projectDir = new File('../node_modules/@capacitor/push-notifications/android')

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

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

Expand Down
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def capacitor_pods
pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
pod 'CapacitorLocalNotifications', :path => '../../node_modules/@capacitor/local-notifications'
pod 'CapacitorPushNotifications', :path => '../../node_modules/@capacitor/push-notifications'
pod 'CapacitorScreenOrientation', :path => '../../node_modules/@capacitor/screen-orientation'
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
pod 'CapawesomeCapacitorAppUpdate', :path => '../../node_modules/@capawesome/capacitor-app-update'
Expand Down
8 changes: 7 additions & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ PODS:
- Capacitor
- CapacitorPushNotifications (6.0.2):
- Capacitor
- CapacitorScreenOrientation (6.0.2):
- Capacitor
- CapacitorShare (6.0.2):
- Capacitor
- CapacitorSplashScreen (6.0.2):
Expand Down Expand Up @@ -162,6 +164,7 @@ DEPENDENCIES:
- "CapacitorFirebasePerformance (from `../../node_modules/@capacitor-firebase/performance`)"
- "CapacitorLocalNotifications (from `../../node_modules/@capacitor/local-notifications`)"
- "CapacitorPushNotifications (from `../../node_modules/@capacitor/push-notifications`)"
- "CapacitorScreenOrientation (from `../../node_modules/@capacitor/screen-orientation`)"
- "CapacitorShare (from `../../node_modules/@capacitor/share`)"
- "CapacitorSplashScreen (from `../../node_modules/@capacitor/splash-screen`)"
- "CapawesomeCapacitorAppUpdate (from `../../node_modules/@capawesome/capacitor-app-update`)"
Expand Down Expand Up @@ -218,6 +221,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capacitor/local-notifications"
CapacitorPushNotifications:
:path: "../../node_modules/@capacitor/push-notifications"
CapacitorScreenOrientation:
:path: "../../node_modules/@capacitor/screen-orientation"
CapacitorShare:
:path: "../../node_modules/@capacitor/share"
CapacitorSplashScreen:
Expand All @@ -239,6 +244,7 @@ SPEC CHECKSUMS:
CapacitorFirebasePerformance: c806ce7f8270295465c050210d8e8a4ae2dc282e
CapacitorLocalNotifications: 6bac9e948b2b8852506c6d74abb2cde140250f86
CapacitorPushNotifications: ccd797926c030acad3d5498ef452c735c90a2c89
CapacitorScreenOrientation: 6039dc2ea4a8596b79316709d5727e8bb7e32845
CapacitorShare: 591ae4693d85686ceb590db8e8b44aa014ec6490
CapacitorSplashScreen: 250df9ef8014fac5c7c1fd231f0f8b1d8f0b5624
CapawesomeCapacitorAppUpdate: 3c05b5c8e42f9c6a88d666093406e9336d9bfdb1
Expand All @@ -264,6 +270,6 @@ SPEC CHECKSUMS:
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21

PODFILE CHECKSUM: a6362e50008bd5aea904cdd9ec858da94a7f155c
PODFILE CHECKSUM: 131ec70809fe3dec63113a003a42e6009560dcef

COCOAPODS: 1.15.2
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@capacitor/ios": "^6.0.0",
"@capacitor/local-notifications": "^6.0.0",
"@capacitor/push-notifications": "^6.0.0",
"@capacitor/screen-orientation": "^6.0.2",
"@capacitor/share": "^6.0.0",
"@capacitor/splash-screen": "^6.0.0",
"@capawesome/capacitor-app-update": "^6.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/data-models/flowTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ export namespace FlowTypes {
"process_template",
"reset_app",
"save_to_device",
"screen_orientation",
"set_field",
"set_item",
"set_items",
Expand Down
5 changes: 4 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { FeedbackService } from "./feature/feedback/feedback.service";
import { ShareService } from "./shared/services/share/share.service";
import { LocalStorageService } from "./shared/services/local-storage/local-storage.service";
import { DeploymentService } from "./shared/services/deployment/deployment.service";
import { ScreenOrientationService } from "./shared/services/screen-orientation/screen-orientation.service";

@Component({
selector: "app-root",
Expand Down Expand Up @@ -111,7 +112,8 @@ export class AppComponent {
private appUpdateService: AppUpdateService,
private remoteAssetService: RemoteAssetService,
private shareService: ShareService,
private fileManagerService: FileManagerService
private fileManagerService: FileManagerService,
private screenOrientationService: ScreenOrientationService
) {
this.initializeApp();
}
Expand Down Expand Up @@ -249,6 +251,7 @@ export class AppComponent {
this.feedbackService,
this.shareService,
this.fileManagerService,
this.screenOrientationService,
],
deferred: [this.analyticsService],
implicit: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from "@angular/core/testing";

import { ScreenOrientationService } from "./screen-orientation.service";

describe("ScreenOrientationService", () => {
let service: ScreenOrientationService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ScreenOrientationService);
});

it("should be created", () => {
expect(service).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Injectable } from "@angular/core";
import { SyncServiceBase } from "../syncService.base";
import { ScreenOrientation, OrientationLockType } from "@capacitor/screen-orientation";
import { TemplateActionRegistry } from "../../components/template/services/instance/template-action.registry";

const ORIENTATION_TYPES: OrientationLockType[] = ["portrait", "landscape"];

@Injectable({
providedIn: "root",
})
export class ScreenOrientationService extends SyncServiceBase {
constructor(private templateActionRegistry: TemplateActionRegistry) {
super("Screen Orientation Service");
this.initialise();
}

initialise() {
this.registerTemplateActionHandlers();
}

private registerTemplateActionHandlers() {
this.templateActionRegistry.register({
screen_orientation: async ({ args }) => {
const [targetOrientation] = args;
if (ORIENTATION_TYPES.includes(targetOrientation)) {
this.setOrientation(targetOrientation);
} else {
console.error(`[SCREEN ORIENTATION] - Invalid orientation: ${targetOrientation}`);
}
},
});
}

private async setOrientation(orientation: OrientationLockType) {
return await ScreenOrientation.lock({ orientation });
}
}
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,15 @@ __metadata:
languageName: node
linkType: hard

"@capacitor/screen-orientation@npm:^6.0.2":
version: 6.0.2
resolution: "@capacitor/screen-orientation@npm:6.0.2"
peerDependencies:
"@capacitor/core": ^6.0.0
checksum: d7e431f9c42373d71d2d6b062ba3fc2fc1e4b034b02166b13c7ba4366e932e61c7558ae6e0429a84a7273f246ea42b23d3ae673ca8a8e7e60517f85d9bd41b22
languageName: node
linkType: hard

"@capacitor/share@npm:^6.0.0":
version: 6.0.2
resolution: "@capacitor/share@npm:6.0.2"
Expand Down Expand Up @@ -14955,6 +14964,7 @@ __metadata:
"@capacitor/ios": ^6.0.0
"@capacitor/local-notifications": ^6.0.0
"@capacitor/push-notifications": ^6.0.0
"@capacitor/screen-orientation": ^6.0.2
"@capacitor/share": ^6.0.0
"@capacitor/splash-screen": ^6.0.0
"@capawesome/capacitor-app-update": ^6.0.0
Expand Down

0 comments on commit dd4f459

Please sign in to comment.