diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index eb35c79a..c544bdf5 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -23,7 +23,6 @@

{{ site.title }}

crossorigin="anonymous"> diff --git a/khelo/assets/images/ic_share.svg b/khelo/assets/images/ic_share.svg new file mode 100644 index 00000000..6fbe76a7 --- /dev/null +++ b/khelo/assets/images/ic_share.svg @@ -0,0 +1,3 @@ + + + diff --git a/khelo/assets/images/ic_star.svg b/khelo/assets/images/ic_star.svg new file mode 100644 index 00000000..bc1a2d56 --- /dev/null +++ b/khelo/assets/images/ic_star.svg @@ -0,0 +1,3 @@ + + + diff --git a/khelo/assets/locales/app_en.arb b/khelo/assets/locales/app_en.arb index cd2ecaab..c91daae3 100644 --- a/khelo/assets/locales/app_en.arb +++ b/khelo/assets/locales/app_en.arb @@ -960,10 +960,23 @@ "profile_setting_contact_support": "Contact support", "profile_setting_privacy_policy_title": "Privacy policy", "profile_setting_terms_and_condition_title": "Terms and condition", + "profile_setting_share_app_title": "Share app", + "profile_setting_rate_us_title": "Rate us", "profile_setting_app_version_text": "App Version: {version}", "profile_setting_scan_to_play_text": "Scan to play!", "profile_setting_scan_to_play_description": "This QR code allows you to easily add the player to the team.", "profile_setting_use_scanner_description": "Use your phone camera or a QR code app to scan the code above and easily add the player to the team.", + "profile_setting_share_app_message": "Elevate your cricket scoring game with Khelo! šŸ\n\nEffortlessly score matches, track stats, and manage your teams.\n\nšŸ‘‰ Download Now:\nšŸ“± Android: {androidLink}\nšŸŽ iOS: {iosLink}\n\nStart scoring smarter today!", + "@profile_setting_share_app_message" : { + "placeholders": { + "androidLink": { + "type": "String" + }, + "iosLink": { + "type": "String" + } + } + }, "@_NOTIFICATION": { }, diff --git a/khelo/ios/Podfile.lock b/khelo/ios/Podfile.lock index a32d3ddf..41e0e8c0 100644 --- a/khelo/ios/Podfile.lock +++ b/khelo/ios/Podfile.lock @@ -1443,6 +1443,8 @@ PODS: - Flutter - MTBBarcodeScanner - RecaptchaInterop (100.0.0) + - share_plus (0.0.1): + - Flutter - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS @@ -1474,6 +1476,7 @@ DEPENDENCIES: - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - qr_code_scanner (from `.symlinks/plugins/qr_code_scanner/ios`) + - share_plus (from `.symlinks/plugins/share_plus/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite (from `.symlinks/plugins/sqflite/darwin`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) @@ -1553,6 +1556,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/permission_handler_apple/ios" qr_code_scanner: :path: ".symlinks/plugins/qr_code_scanner/ios" + share_plus: + :path: ".symlinks/plugins/share_plus/ios" shared_preferences_foundation: :path: ".symlinks/plugins/shared_preferences_foundation/darwin" sqflite: @@ -1611,6 +1616,7 @@ SPEC CHECKSUMS: PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21 + share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e diff --git a/khelo/ios/Runner/Info.plist b/khelo/ios/Runner/Info.plist index bd7c7ebf..58913373 100644 --- a/khelo/ios/Runner/Info.plist +++ b/khelo/ios/Runner/Info.plist @@ -72,5 +72,9 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + LSApplicationQueriesSchemes + + itms-apps + diff --git a/khelo/lib/gen/assets.gen.dart b/khelo/lib/gen/assets.gen.dart index 78bc900a..81ff822a 100644 --- a/khelo/lib/gen/assets.gen.dart +++ b/khelo/lib/gen/assets.gen.dart @@ -106,9 +106,15 @@ class $AssetsImagesGen { /// File path: assets/images/ic_search.svg String get icSearch => 'assets/images/ic_search.svg'; + /// File path: assets/images/ic_share.svg + String get icShare => 'assets/images/ic_share.svg'; + /// File path: assets/images/ic_sign_out.svg String get icSignOut => 'assets/images/ic_sign_out.svg'; + /// File path: assets/images/ic_star.svg + String get icStar => 'assets/images/ic_star.svg'; + /// File path: assets/images/ic_stats.svg String get icStats => 'assets/images/ic_stats.svg'; @@ -179,7 +185,9 @@ class $AssetsImagesGen { icSave, icScorer, icSearch, + icShare, icSignOut, + icStar, icStats, icTermsConditions, icTime, diff --git a/khelo/lib/ui/flow/profile/profile_screen.dart b/khelo/lib/ui/flow/profile/profile_screen.dart index 74d6fed8..506fe38c 100644 --- a/khelo/lib/ui/flow/profile/profile_screen.dart +++ b/khelo/lib/ui/flow/profile/profile_screen.dart @@ -31,6 +31,13 @@ class ProfileScreen extends ConsumerStatefulWidget { class _ProfileScreenState extends ConsumerState with WidgetsBindingObserver { + final privacyPolicyUrl = "https://canopas.github.io/khelo/privacy-policy"; + final termsAndConditionsUrl = + "https://canopas.github.io/khelo/terms-and-condition"; + final playStoreLink = + "https://play.google.com/store/apps/details?id=com.canopas.khelo"; + final appStoreLink = "https://apps.apple.com/app/khelo/id6480175424"; + late ProfileViewNotifier notifier; @override @@ -189,15 +196,27 @@ class _ProfileScreenState extends ConsumerState context, icon: Assets.images.icPrivacyPolicy, title: context.l10n.profile_setting_privacy_policy_title, - onTap: () => notifier - .openUrl("https://canopas.github.io/khelo/privacy-policy"), + onTap: () => notifier.openUrl(privacyPolicyUrl), ), _settingItem( context, icon: Assets.images.icTermsConditions, title: context.l10n.profile_setting_terms_and_condition_title, - onTap: () => notifier - .openUrl("https://canopas.github.io/khelo/terms-and-condition"), + onTap: () => notifier.openUrl(termsAndConditionsUrl), + ), + _settingItem( + context, + icon: Assets.images.icShare, + title: context.l10n.profile_setting_share_app_title, + onTap: () => notifier.onShareApp(context.l10n + .profile_setting_share_app_message( + playStoreLink, appStoreLink)), + ), + _settingItem( + context, + icon: Assets.images.icStar, + title: context.l10n.profile_setting_rate_us_title, + onTap: () => notifier.onRateUs(), ), _settingItem( context, diff --git a/khelo/lib/ui/flow/profile/profile_view_model.dart b/khelo/lib/ui/flow/profile/profile_view_model.dart index 80a39de7..4764e373 100644 --- a/khelo/lib/ui/flow/profile/profile_view_model.dart +++ b/khelo/lib/ui/flow/profile/profile_view_model.dart @@ -1,12 +1,15 @@ +import 'dart:io'; + import 'package:data/api/user/user_models.dart'; import 'package:data/service/auth/auth_service.dart'; import 'package:data/service/device/device_service.dart'; import 'package:data/service/user/user_service.dart'; import 'package:data/storage/app_preferences.dart'; -import 'package:flutter/rendering.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:url_launcher/url_launcher.dart'; part 'profile_view_model.freezed.dart'; @@ -25,6 +28,8 @@ final profileStateProvider = }); class ProfileViewNotifier extends StateNotifier { + static const String webFallbackUrl = 'https://github.com/canopas/khelo'; + final AuthService _authService; final DeviceService _deviceService; final UserService _userService; @@ -104,6 +109,30 @@ class ProfileViewNotifier extends StateNotifier { state = state.copyWith(shouldShowNotificationBanner: false); } } + + Future onRateUs() async { + try { + final packageName = await _deviceService.packageName; + final targetUrl = (!kIsWeb && Platform.isAndroid) + ? "market://details?id=$packageName" + : (!kIsWeb && Platform.isIOS) + ? "itms-apps://itunes.apple.com/app/6480175424" + : webFallbackUrl; + await launchUrl(Uri.parse(targetUrl)); + } catch (e) { + state = state.copyWith(actionError: e); + debugPrint("ProfileViewNotifier: error while rate us -> $e"); + } + } + + Future onShareApp(String shareString) async { + try { + await Share.share(shareString); + } catch (e) { + state = state.copyWith(actionError: e); + debugPrint("ProfileViewNotifier: error while share app -> $e"); + } + } } @freezed diff --git a/khelo/lib/ui/flow/profile/profile_view_model.freezed.dart b/khelo/lib/ui/flow/profile/profile_view_model.freezed.dart index 6dad9fab..783fc51c 100644 --- a/khelo/lib/ui/flow/profile/profile_view_model.freezed.dart +++ b/khelo/lib/ui/flow/profile/profile_view_model.freezed.dart @@ -164,7 +164,7 @@ class __$$ProfileStateImplCopyWithImpl<$Res> /// @nodoc -class _$ProfileStateImpl implements _ProfileState { +class _$ProfileStateImpl with DiagnosticableTreeMixin implements _ProfileState { const _$ProfileStateImpl( {this.actionError, this.currentUser, @@ -186,10 +186,24 @@ class _$ProfileStateImpl implements _ProfileState { final bool shouldShowNotificationBanner; @override - String toString() { + String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) { return 'ProfileState(actionError: $actionError, currentUser: $currentUser, appVersion: $appVersion, enableUserNotification: $enableUserNotification, shouldShowNotificationBanner: $shouldShowNotificationBanner)'; } + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + ..add(DiagnosticsProperty('type', 'ProfileState')) + ..add(DiagnosticsProperty('actionError', actionError)) + ..add(DiagnosticsProperty('currentUser', currentUser)) + ..add(DiagnosticsProperty('appVersion', appVersion)) + ..add( + DiagnosticsProperty('enableUserNotification', enableUserNotification)) + ..add(DiagnosticsProperty( + 'shouldShowNotificationBanner', shouldShowNotificationBanner)); + } + @override bool operator ==(Object other) { return identical(this, other) || diff --git a/khelo/macos/Flutter/GeneratedPluginRegistrant.swift b/khelo/macos/Flutter/GeneratedPluginRegistrant.swift index 9019b189..2a9a9a92 100644 --- a/khelo/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/khelo/macos/Flutter/GeneratedPluginRegistrant.swift @@ -18,6 +18,7 @@ import flutter_local_notifications import flutter_timezone import package_info_plus import path_provider_foundation +import share_plus import shared_preferences_foundation import sqflite import url_launcher_macos @@ -36,6 +37,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FlutterTimezonePlugin.register(with: registry.registrar(forPlugin: "FlutterTimezonePlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) + SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) diff --git a/khelo/pubspec.lock b/khelo/pubspec.lock index 95b46f17..5d0c5a70 100644 --- a/khelo/pubspec.lock +++ b/khelo/pubspec.lock @@ -1297,6 +1297,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.28.0" + share_plus: + dependency: "direct main" + description: + name: share_plus + sha256: "9c9bafd4060728d7cdb2464c341743adbd79d327cb067ec7afb64583540b47c8" + url: "https://pub.dev" + source: hosted + version: "10.1.2" + share_plus_platform_interface: + dependency: transitive + description: + name: share_plus_platform_interface + sha256: c57c0bbfec7142e3a0f55633be504b796af72e60e3c791b44d5a017b985f7a48 + url: "https://pub.dev" + source: hosted + version: "5.0.1" shared_preferences: dependency: "direct main" description: diff --git a/khelo/pubspec.yaml b/khelo/pubspec.yaml index 971b55d2..1f781da9 100644 --- a/khelo/pubspec.yaml +++ b/khelo/pubspec.yaml @@ -41,6 +41,7 @@ dependencies: shared_preferences: ^2.3.2 collection: any + share_plus: ^10.1.2 # UI cupertino_icons: ^1.0.8 diff --git a/khelo/windows/flutter/generated_plugin_registrant.cc b/khelo/windows/flutter/generated_plugin_registrant.cc index cf6e4802..759f8825 100644 --- a/khelo/windows/flutter/generated_plugin_registrant.cc +++ b/khelo/windows/flutter/generated_plugin_registrant.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { @@ -30,6 +31,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("FlutterTimezonePluginCApi")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); + SharePlusWindowsPluginCApiRegisterWithRegistrar( + registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/khelo/windows/flutter/generated_plugins.cmake b/khelo/windows/flutter/generated_plugins.cmake index 6bd17d60..7ae15f8d 100644 --- a/khelo/windows/flutter/generated_plugins.cmake +++ b/khelo/windows/flutter/generated_plugins.cmake @@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST firebase_storage flutter_timezone permission_handler_windows + share_plus url_launcher_windows )