From 2ba43afdaf2b01d3ca35e99c92ed9353de44d998 Mon Sep 17 00:00:00 2001 From: Zied Dahmani Date: Thu, 23 Nov 2023 17:57:45 +0100 Subject: [PATCH] feat: Share app --- .gitignore | 1 + .../controllers/scan_controller.dart | 5 +++ lib/config/locale.dart | 4 +- lib/data/repositories/barcode_repository.dart | 2 +- lib/presentation/views/scan_screen.dart | 38 ++++++++++++------- pubspec.yaml | 1 + 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 00e2603..aebcf00 100644 --- a/.gitignore +++ b/.gitignore @@ -141,4 +141,5 @@ app.*.symbols key.properties app/upload-keystore.jks +# Environment variables .env diff --git a/lib/application/controllers/scan_controller.dart b/lib/application/controllers/scan_controller.dart index 62c66cb..b008525 100644 --- a/lib/application/controllers/scan_controller.dart +++ b/lib/application/controllers/scan_controller.dart @@ -10,6 +10,7 @@ import 'package:qataa/application/services/connectivity_service.dart'; import 'package:qataa/application/usecases/scan_barcode_use_case.dart'; import 'package:qataa/presentation/widgets/bottom_sheet_content.dart'; import 'package:qataa/utils/screen_util.dart'; +import 'package:share_plus/share_plus.dart'; import 'dart:developer' as developer; import 'package:url_launcher/url_launcher.dart'; @@ -110,4 +111,8 @@ class ScanController extends GetxController { throw 'Could not launch $uri'; } } + + Future shareApp() async { + await Share.shareUri(Uri.parse('https://play.google.com/store/apps/details?id=com.rebounddev.qataa')); + } } diff --git a/lib/config/locale.dart b/lib/config/locale.dart index c83948d..f885cd9 100644 --- a/lib/config/locale.dart +++ b/lib/config/locale.dart @@ -16,11 +16,11 @@ class Locale implements Translations { 'connectivityProblemTitle': 'إنترنت', 'connectivityProblemSubtitle': 'ثبت عندك إنترنت ولا', 'scanOnBoardingTitle': 'سكاني المنتج', - 'scanOnBoardingBody': 'بش تعرفو ضمن قائمة المقاطعة ولا تنجم تشريه', + 'scanOnBoardingBody': 'بش تعرفو موجود في قائمة المقاطعة ولا تنجم تشريه', 'emailOnBoardingTitle': 'استفسارات', 'emailOnBoardingBody': 'كان تحب تسأل على حاجة تنجم تبعثلنا بريد إلكتروني', 'alertTitle': 'تنبيه', - 'alertSubtitle': 'كل مرة قعدين نزيدو في منتج إلى قائمة المقاطعة.', + 'alertSubtitle': 'كل مرة قاعدين نزيدو في منتج إلى قائمة المقاطعة.', 'ok': 'مفهوم', }, }; diff --git a/lib/data/repositories/barcode_repository.dart b/lib/data/repositories/barcode_repository.dart index 41fa59b..01c81b5 100644 --- a/lib/data/repositories/barcode_repository.dart +++ b/lib/data/repositories/barcode_repository.dart @@ -13,7 +13,7 @@ class BarcodeRepository implements IBarcodeRepository { final boycottList = await _boycottDataSource.fetchBoycottList(); final result = await _barcodeDataProvider.fetchBarcodeData(barcode); - return ['brand', 'desciption','manufacturer','title'].any((attribute) { + return ['brand', 'description','manufacturer','title'].any((attribute) { final attributeValue = result.data['product'][attribute]; if (attributeValue != null) { final lowerCasedValue = attributeValue.toLowerCase(); diff --git a/lib/presentation/views/scan_screen.dart b/lib/presentation/views/scan_screen.dart index f7fc0d4..c6c17db 100644 --- a/lib/presentation/views/scan_screen.dart +++ b/lib/presentation/views/scan_screen.dart @@ -1,3 +1,4 @@ +// ignore_for_file: use_build_context_synchronously import 'package:flutter/material.dart'; import 'package:onboarding_overlay/onboarding_overlay.dart'; import 'package:qataa/application/controllers/scan_controller.dart'; @@ -42,13 +43,6 @@ class _ScanScreenState extends State with WidgetsBindingObserver { }); } - @override - void didChangeAppLifecycleState(AppLifecycleState state) { - if (state == AppLifecycleState.resumed) { - ScreenUtil.CustomSystemChrome(context); - } - } - void setVisible(){ setState(() { isVisible = true; @@ -58,18 +52,36 @@ class _ScanScreenState extends State with WidgetsBindingObserver { } } + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + if (state == AppLifecycleState.resumed) { + ScreenUtil.CustomSystemChrome(context); + } + } + @override Widget build(BuildContext context) { return WillPopScope( onWillPop: () async => false, child: Scaffold( appBar: AppBar( - leading: IconButton( - icon: const Icon(FontAwesomeIcons.solidEnvelope), - onPressed: () { - _scanController.sendEmail(); - }, - ), + title: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + IconButton( + icon: const Icon(FontAwesomeIcons.solidEnvelope), + onPressed: () { + _scanController.sendEmail(); + }, + ), + IconButton( + icon: const Icon(FontAwesomeIcons.share), + onPressed: () { + _scanController.shareApp(); + }, + ), + ], + ) ), body: GetX(builder: (_) { if (_scanController.state is VerificationLoadInProgress) { diff --git a/pubspec.yaml b/pubspec.yaml index 7d0eab9..f58bba7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,6 +43,7 @@ dependencies: onboarding_overlay: ^3.2.1 shared_preferences: ^2.2.0 flutter_dotenv: ^5.1.0 + share_plus: ^7.2.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2