Skip to content

Commit

Permalink
swipe back on ios enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
RemcoSimonides committed Nov 26, 2023
1 parent bcab51c commit 881f648
Show file tree
Hide file tree
Showing 13 changed files with 2,801 additions and 782 deletions.
8 changes: 4 additions & 4 deletions apps/journal/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 33;
CURRENT_PROJECT_VERSION = 51;
DEVELOPMENT_TEAM = 2Z8SN3C4MM;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Strive Journal";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.8.1;
MARKETING_VERSION = 1.12.0;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = com.strive.journal;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -376,13 +376,13 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 33;
CURRENT_PROJECT_VERSION = 51;
DEVELOPMENT_TEAM = 2Z8SN3C4MM;
INFOPLIST_FILE = App/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Strive Journal";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.8.1;
MARKETING_VERSION = 1.12.0;
PRODUCT_BUNDLE_IDENTIFIER = com.strive.journal;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
Expand Down
30 changes: 16 additions & 14 deletions apps/journal/ios/App/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative '../../../../node_modules/@capacitor/ios/scripts/pods_helpers'
require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers'

platform :ios, '13.0'
use_frameworks!
Expand All @@ -9,24 +9,26 @@ use_frameworks!
install! 'cocoapods', :disable_input_output_paths => true

def capacitor_pods
pod 'Capacitor', :path => '../../../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../../../node_modules/@capacitor/ios'
pod 'CapacitorApp', :path => '../../../../node_modules/@capacitor/app'
pod 'CapacitorCamera', :path => '../../../../node_modules/@capacitor/camera'
pod 'CapacitorClipboard', :path => '../../../../node_modules/@capacitor/clipboard'
pod 'CapacitorKeyboard', :path => '../../../../node_modules/@capacitor/keyboard'
pod 'CapacitorPushNotifications', :path => '../../../../node_modules/@capacitor/push-notifications'
pod 'CapacitorShare', :path => '../../../../node_modules/@capacitor/share'
pod 'CapacitorSplashScreen', :path => '../../../../node_modules/@capacitor/splash-screen'
pod 'CapacitorCommunityFcm', :path => '../../../../node_modules/@capacitor-community/fcm'
pod 'CapacitorFirebaseAuthentication', :path => '../../../../node_modules/@capacitor-firebase/authentication'
pod 'CapawesomeCapacitorAppUpdate', :path => '../../../../node_modules/@capawesome/capacitor-app-update'
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCommunityFcm', :path => '../../node_modules/@capacitor-community/fcm'
pod 'CapacitorFirebaseAuthentication', :path => '../../node_modules/@capacitor-firebase/authentication'
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
pod 'CapacitorCamera', :path => '../../node_modules/@capacitor/camera'
pod 'CapacitorClipboard', :path => '../../node_modules/@capacitor/clipboard'
pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
pod 'CapacitorPushNotifications', :path => '../../node_modules/@capacitor/push-notifications'
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
pod 'CapawesomeCapacitorAppUpdate', :path => '../../node_modules/@capawesome/capacitor-app-update'
pod 'CapacitorPluginIosWebviewConfigurator', :path => '../../node_modules/capacitor-plugin-ios-webview-configurator'
end

target 'App' do
capacitor_pods
# Add your Pods here
pod 'CapacitorFirebaseAuthentication/Google', :path => '../../../../node_modules/@capacitor-firebase/authentication'
pod 'CapacitorFirebaseAuthentication/Lite', :path => '../../node_modules/@capacitor-firebase/authentication'
pod 'CapacitorFirebaseAuthentication/Google', :path => '../../node_modules/@capacitor-firebase/authentication'
end

post_install do |installer|
Expand Down
80 changes: 66 additions & 14 deletions apps/journal/package-lock.json

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

6 changes: 4 additions & 2 deletions apps/journal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
"@capacitor-firebase/authentication": "^5.2.0",
"@capacitor/app": "^5.0.6",
"@capacitor/camera": "^5.0.7",
"@capacitor/cli": "^5.5.1",
"@capacitor/cli": "^5.0.5",
"@capacitor/clipboard": "^5.0.6",
"@capacitor/ios": "5.5.1",
"@capacitor/keyboard": "^5.0.6",
"@capacitor/push-notifications": "^5.1.0",
"@capacitor/share": "^5.0.6",
"@capacitor/splash-screen": "^5.0.6",
"@capawesome/capacitor-app-update": "^5.0.1"
"@capawesome/capacitor-app-update": "^5.0.1",
"capacitor-plugin-ios-webview-configurator": "^0.4.0"
}
}
6 changes: 6 additions & 0 deletions apps/journal/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { PWAService } from '@strive/utils/services/pwa.service'
import * as Sentry from '@sentry/capacitor'
import * as SentryAngular from '@sentry/angular'

import { setBackForwardNavigationGestures, setWebviewBounce } from 'capacitor-plugin-ios-webview-configurator'

Sentry.init(
{
dsn: 'https://[email protected]/6638131',
Expand Down Expand Up @@ -73,5 +75,9 @@ Sentry.init(
export class AppModule {
constructor(pwa: PWAService) {
pwa.addEventListeners()

// console.log('registering webview config')
setWebviewBounce(true)
setBackForwardNavigationGestures(true)
}
}
2 changes: 1 addition & 1 deletion apps/journal/src/app/pages/tabs/tabs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ion-label [color]="(homeActive$ | async) ? 'primary' : 'inherit'">Goals</ion-label>
</ion-tab-button>

<ion-tab-button tab="exercise" [routerLink]="['/exercise']">
<ion-tab-button tab="exercise" routerLink="/exercise" routerDirection="root">
<ion-icon
name="barbell-sharp"
[color]="(exerciseActive$ | async) ? 'primary' : 'inherit'"
Expand Down
4 changes: 0 additions & 4 deletions apps/journal/src/app/pages/tabs/tabs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export class TabsComponent {
map(nav => nav.url.startsWith('/supports'))
)

exploreActive$ = this.route$.pipe(
map(nav => nav.url.startsWith('/explore'))
)

exerciseActive$ = this.route$.pipe(
map(nav => nav.url.startsWith('/exercise'))
)
Expand Down
9 changes: 5 additions & 4 deletions libs/auth/src/lib/components/auth-modal/auth-modal.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,14 @@ export class AuthModalComponent implements OnInit {
this.oAuthLogin(credentials.user)

} catch (error: any) {
let code = undefined
if (error?.code) code = error.code
if (error?.error) code = error.error
const code = error?.code ?? error?.error ?? error?.message

switch (code) {
case '12501':
case 'popup_closed_by_user':
case 'auth/popup-closed-by-user':
case 'auth/popup-blocked':
case 'The user canceled the sign-in flow.':
break
default:
captureException(error)
Expand All @@ -187,10 +186,12 @@ export class AuthModalComponent implements OnInit {

} catch (error: any) {
if (error == 'Error: The web operation was canceled by the user.') return
const code = error?.code ?? error?.error ?? error?.message

switch (error.code) {
switch (code) {
case 'auth/popup-closed-by-user':
case 'auth/popup-blocked':
case `The operation couldn’t be completed. (com.apple.AuthenticationServices.AuthorizationError error 1001.)`:
break
default:
captureException(error)
Expand Down
15 changes: 12 additions & 3 deletions libs/utils/src/lib/directives/modal.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,27 @@ import { delay } from '../helpers'
export class ModalDirective {
private data?: unknown
private isWeb = Capacitor.getPlatform() === 'web'
private isIOS = Capacitor.getPlatform() === 'ios'

@HostBinding() modal?: HTMLIonModalElement
@HostListener('window:popstate', ['$event'])
onPopState() {
this.modalCtrl.dismiss(this.data)
if (this.isIOS) {
this.modalCtrl.getTop().then(modal => {
if (!modal) return this.modalCtrl.dismiss()
modal.animated = false
return modal.dismiss()
})
} else {
this.modalCtrl.dismiss(this.data)
}
}

constructor(
protected location: Location,
protected modalCtrl: ModalController
) {
if (this.isWeb) {
if (this.isWeb || this.isIOS) {
window.history.pushState(null, '', window.location.href)

this.modalCtrl.getTop().then(() => {
Expand Down Expand Up @@ -50,7 +59,7 @@ export class ModalDirective {
}

navigateTo(router: Router, path: string[]) {
if (this.isWeb) {
if (this.isWeb || this.isIOS) {
this.location.back()
delay(250).then(() => {
router.navigate(path)
Expand Down
5 changes: 3 additions & 2 deletions libs/utils/src/lib/directives/popover.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class PopoverDirective {
private returnData: unknown
private returnRole?: string
private isWeb = Capacitor.getPlatform() === 'web'
private isIOS = Capacitor.getPlatform() === 'ios'

@HostBinding() popover?: HTMLIonPopoverElement
@HostListener('window:popstate', ['$event'])
Expand All @@ -22,7 +23,7 @@ export class PopoverDirective {
protected platform: Platform,
protected popoverCtrl: PopoverController
) {
if (this.isWeb) {
if (this.isWeb || this.isIOS) {
window.history.pushState(null, '', window.location.href)

this.popoverCtrl.getTop().then(() => {
Expand All @@ -34,7 +35,7 @@ export class PopoverDirective {
}

dismiss(data?: unknown, role?: string) {
if (this.isWeb) {
if (this.isWeb || this.isIOS) {
this.returnData = data
this.returnRole = role
this.location.back()
Expand Down
1 change: 0 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"npmScope": "strive",
"affected": {
"defaultBase": "master"
},
Expand Down
Loading

0 comments on commit 881f648

Please sign in to comment.