diff --git a/app/app.ts b/app/app.ts index ab6d6995..e1c1f9a3 100644 --- a/app/app.ts +++ b/app/app.ts @@ -109,6 +109,11 @@ try { DrawerElement.register(); startSentry(); initialize({ isDownsampleEnabled: true }); + + if (PLAY_STORE_BUILD) { + import('@shared/utils/inapp-purchase').then((r) => r.init()); + } + // Trace.addCategories(Trace.categories.Navigation); // Trace.addCategories(Trace.categories.Transition); // Trace.addCategories(Trace.categories.Accessibility); diff --git a/app/components/settings/Settings.svelte b/app/components/settings/Settings.svelte index 3a4b83e5..689a1655 100644 --- a/app/components/settings/Settings.svelte +++ b/app/components/settings/Settings.svelte @@ -66,6 +66,7 @@ import { colors, fonts, hasCamera, windowInset } from '~/variables'; import IconButton from '../common/IconButton.svelte'; import { share } from '@akylas/nativescript-app-utils/share'; + import { inappItems, presentInAppSponsorBottomsheet } from '@shared/utils/inapp-purchase'; const version = __APP_VERSION__ + ' Build ' + __APP_BUILD_NUMBER__; const storeSettings = {}; const variant = 'outline'; @@ -85,6 +86,8 @@ let items: ObservableArray; + const inAppAvailable = PLAY_STORE_BUILD && inappItems?.length > 0; + export let title = null; export let actionBarButtons = [ { icon: 'mdi-share-variant', id: 'share' }, @@ -517,7 +520,7 @@ [ { type: 'header', - title: __IOS__ ? lc('show_love') : lc('donate') + title: __IOS__ && !inAppAvailable ? lc('show_love') : lc('donate') }, { type: 'sectionheader', @@ -959,9 +962,24 @@ openLink(STORE_REVIEW_LINK); break; case 'sponsor': - // Apple wants us to use in-app purchase for donations => taking 30% ... - // so lets just open github and ask for love... - openLink(__IOS__ ? GIT_URL : SPONSOR_URL); + switch (item.type) { + case 'librepay': + openLink('https://liberapay.com/farfromrefuge'); + break; + case 'patreon': + openLink('https://patreon.com/farfromrefuge'); + break; + + default: + if (inAppAvailable) { + presentInAppSponsorBottomsheet(); + } else { + // Apple wants us to use in-app purchase for donations => taking 30% ... + // so lets just open github and ask for love... + openLink(__IOS__ ? GIT_URL : SPONSOR_URL); + } + break; + } break; case 'third_party': const ThirdPartySoftwareBottomSheet = (await import('~/components/settings/ThirdPartySoftwareBottomSheet.svelte')).default; diff --git a/app/i18n/en.json b/app/i18n/en.json index 767608ad..2fcae0bb 100644 --- a/app/i18n/en.json +++ b/app/i18n/en.json @@ -201,6 +201,18 @@ "import_settings_desc": "import all settings from a previous backup", "imported_nb_pages": "imported %1$s pages", "internal_storage": "internal storage", + "inapp":{ + "smalltip": "a coffee", + "smalltip_desc": "everything helps to work at night!", + "mediumtip": "a big coffee", + "mediumtip_desc": "my eyes are open!", + "largetip": "a beer", + "largetip_desc": "chill out and go back to work!", + "largertip": "a pint", + "largertip_desc": "ideas are going to flow!", + "bigtip": "a very nice donation", + "bigtip_desc": "new features are coming!" + }, "invalid": "invalid", "ios": { "info": { diff --git a/package.json b/package.json index eb8534dd..7f3d7b1e 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@akylas/nativescript": "8.8.10", "@akylas/nativescript-app-tools": "file:tools", "@akylas/nativescript-app-utils": "2.2.1", + "@akylas/nativescript-inapp-purchase": "^0.0.3", "@akylas/nativescript-inappbrowser": "3.1.8", "@akylas/panzoom": "4.6.0", "@mdi/font": "7.4.47", diff --git a/tools b/tools index def4e123..6cbaf9fa 160000 --- a/tools +++ b/tools @@ -1 +1 @@ -Subproject commit def4e12360d67a611133dfff49886033f20b0f26 +Subproject commit 6cbaf9fa8bb172c7ecf64ad5630bab88143d42c3 diff --git a/yarn.lock b/yarn.lock index aa48584c..44282119 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27,7 +27,7 @@ __metadata: "@akylas/nativescript-app-tools@file:tools::locator=root-workspace-0b6124%40workspace%3A.": version: 1.0.0 - resolution: "@akylas/nativescript-app-tools@file:tools#tools::hash=96949e&locator=root-workspace-0b6124%40workspace%3A." + resolution: "@akylas/nativescript-app-tools@file:tools#tools::hash=0a5721&locator=root-workspace-0b6124%40workspace%3A." dependencies: "@dotenvx/dotenvx": "npm:1.28.0" "@nativescript-community/fontmin": "npm:0.9.11" @@ -82,7 +82,7 @@ __metadata: typescript: "npm:5.7.2" typescript-eslint: "npm:^8.17.0" webpack-bundle-analyzer: "npm:^4.10.2" - checksum: 10/5942d622caaeed385f8bbc1d0ab9708355fae7dadd62b45f7f2e24156f8ef59afea6e0bb478a6fa50b08fb47b8a2a8dccdb08d035c8768154fd7f654a1be7cf8 + checksum: 10/925fdd661d7197b173a3f493fb313d69ccf8ab9b279a34d69887ed4a416780f7cefdba0174e1cb3c8ce7a48038e6ded27c4192593b4b7a31684fcf659afb35d9 languageName: node linkType: hard @@ -95,6 +95,13 @@ __metadata: languageName: node linkType: hard +"@akylas/nativescript-inapp-purchase@npm:^0.0.3": + version: 0.0.3 + resolution: "@akylas/nativescript-inapp-purchase@npm:0.0.3" + checksum: 10/5578732a7f026fb90be78ee26e41665f734a1d051a322f8a1f085203be18e482efee177cc908f680238dc7dcd0ef4523f2c24418d745e5943332937d226d4a9c + languageName: node + linkType: hard + "@akylas/nativescript-inappbrowser@npm:3.1.8": version: 3.1.8 resolution: "@akylas/nativescript-inappbrowser@npm:3.1.8" @@ -10376,6 +10383,7 @@ __metadata: "@akylas/nativescript-android-runtime": "npm:8.8.5" "@akylas/nativescript-app-tools": "file:tools" "@akylas/nativescript-app-utils": "npm:2.2.1" + "@akylas/nativescript-inapp-purchase": "npm:^0.0.3" "@akylas/nativescript-inappbrowser": "npm:3.1.8" "@akylas/nativescript-ios-runtime": "npm:8.8.2" "@akylas/nativescript-webpack": "npm:5.0.22"