Skip to content

Commit

Permalink
Merge branch 'development_cleanup' into development_cleanup_animated_…
Browse files Browse the repository at this point in the history
…logo
  • Loading branch information
AlaaElattar authored Oct 3, 2024
2 parents 0620440 + 05b3c6d commit fe85d38
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 19 deletions.
12 changes: 9 additions & 3 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ PODS:
- qr_code_scanner (0.2.0):
- Flutter
- MTBBarcodeScanner
- screen_brightness_ios (0.1.0):
- Flutter
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand Down Expand Up @@ -56,6 +58,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`)
- screen_brightness_ios (from `.symlinks/plugins/screen_brightness_ios/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- shuftipro_onsite_sdk (from `.symlinks/plugins/shuftipro_onsite_sdk/ios`)
- smart_auth (from `.symlinks/plugins/smart_auth/ios`)
Expand Down Expand Up @@ -91,6 +94,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/permission_handler_apple/ios"
qr_code_scanner:
:path: ".symlinks/plugins/qr_code_scanner/ios"
screen_brightness_ios:
:path: ".symlinks/plugins/screen_brightness_ios/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
shuftipro_onsite_sdk:
Expand All @@ -116,16 +121,17 @@ SPEC CHECKSUMS:
open_filex: 6e26e659846ec990262224a12ef1c528bb4edbe4
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
screen_brightness_ios: 7437207a2a9bc56553aa10f782afecf830b4c4e2
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
ShuftiPro-Onsite: 45989f1626cc7bb7d150954e6d4a3f0cc8a86db9
shuftipro_onsite_sdk: 1e6ca562c98e8dfb7b8e56940d4d00cb5416d7af
smart_auth: 4bedbc118723912d0e45a07e8ab34039c19e04f2
sodium_libs: 0486eb2c3172ce494406367d4b379042444b769d
uni_links: d97da20c7701486ba192624d99bffaaffcfc298a
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
webview_flutter_wkwebview: 2a23822e9039b7b1bc52e5add778e5d89ad488d1

PODFILE CHECKSUM: 2262097366c615de59b03ca3bf748d7aaad51773
Expand Down
31 changes: 24 additions & 7 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:threebotlogin/helpers/globals.dart';
import 'package:threebotlogin/screens/splash_screen.dart';
import 'package:threebotlogin/services/shared_preference_service.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:threebotlogin/widgets/theme_provider.dart';
import 'package:threebotlogin/widgets/wizard/terms_agreement.dart';

extension ColorSchemeExtension on ColorScheme {
Expand Down Expand Up @@ -37,11 +38,24 @@ Future<void> main() async {
String? doubleName = await getDoubleName();

await setGlobalValues();

bool registered = doubleName != null;
runApp(ChangeNotifierProvider(
create: ((context) => TermsAgreement()),
child: MyApp(initDone: initDone, registered: registered)));

ThemeMode initialThemeMode = ThemeMode.system;

ThemeProvider themeProvider = ThemeProvider(initialThemeMode);
await themeProvider.loadTheme();

runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(
create: (context) => themeProvider),
ChangeNotifierProvider(
create: (context) => TermsAgreement()),
],
child: MyApp(initDone: initDone, registered: registered),
),
);
}

Future<void> setGlobalValues() async {
Expand All @@ -56,7 +70,7 @@ Future<void> setGlobalValues() async {
}

class MyApp extends StatelessWidget {
const MyApp({
const MyApp({
super.key,
required this.initDone,
this.doubleName,
Expand All @@ -69,6 +83,8 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
final themeProvider = Provider.of<ThemeProvider>(context);

var kColorScheme = ColorScheme.fromSeed(
brightness: Brightness.light,
seedColor: const Color.fromARGB(255, 26, 161, 143),
Expand Down Expand Up @@ -134,8 +150,9 @@ class MyApp extends StatelessWidget {
unselectedItemColor: kDarkColorScheme.secondary,
),
),
themeMode: ThemeMode.system,
home: SplashScreen(initDone: initDone, registered: registered),
themeMode: themeProvider.themeMode,
home: SplashScreen(
initDone: initDone, registered: registered),
);
}
}
73 changes: 73 additions & 0 deletions app/lib/screens/preference_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';
import 'package:threebotlogin/app_config.dart';
import 'package:threebotlogin/apps/free_flow_pages/ffp_events.dart';
import 'package:threebotlogin/events/close_socket_event.dart';
Expand All @@ -16,6 +18,7 @@ import 'package:threebotlogin/services/fingerprint_service.dart';
import 'package:threebotlogin/services/shared_preference_service.dart';
import 'package:threebotlogin/widgets/custom_dialog.dart';
import 'package:threebotlogin/widgets/layout_drawer.dart';
import 'package:threebotlogin/widgets/theme_provider.dart';
import 'package:url_launcher/url_launcher.dart';

class PreferenceScreen extends StatefulWidget {
Expand Down Expand Up @@ -75,6 +78,15 @@ class _PreferenceScreenState extends State<PreferenceScreen> {

@override
Widget build(BuildContext context) {
final themeProvider = Provider.of<ThemeProvider>(context);
bool isDarkMode;
if (themeProvider.themeMode == ThemeMode.system){
final brightness =
SchedulerBinding.instance.platformDispatcher.platformBrightness;
isDarkMode = brightness == Brightness.dark;
} else {
isDarkMode = themeProvider.themeMode == ThemeMode.dark;
}
return LayoutDrawer(
titleText: 'Settings',
content: ListView(
Expand Down Expand Up @@ -147,6 +159,67 @@ class _PreferenceScreenState extends State<PreferenceScreen> {
_changePincode();
},
),
ListTile(
leading: const Icon(Icons.brightness_6_outlined),
title: const Text('Appearance'),
trailing: GestureDetector(
onTap: () {
themeProvider.toggleTheme();
},
child: Container(
width: 40,
height: 20,
decoration: BoxDecoration(
color: isDarkMode
? Colors.black
: Theme.of(context).colorScheme.primary,
borderRadius: BorderRadius.circular(10),
boxShadow: const [
BoxShadow(
color: Colors.black26,
blurRadius: 4,
offset: Offset(2, 2),
),
],
),
child: Stack(
children: [
AnimatedPositioned(
duration: const Duration(milliseconds: 300),
left: isDarkMode ? 20 : 0,
child: Container(
width: 20,
height: 20,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 4,
offset: Offset(2, 2),
),
],
),
child: Center(
child: Icon(
isDarkMode
? Icons
.nightlight_round
: Icons.wb_sunny,
color: isDarkMode
? Colors.black
: Theme.of(context).colorScheme.primary,
size: 14,
),
),
),
),
],
),
),
),
),
ListTile(
leading: const Icon(Icons.perm_device_information),
title: Text('Version: $version - $buildNumber'),
Expand Down
13 changes: 13 additions & 0 deletions app/lib/services/shared_preference_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,16 @@ Future<void> setPKidMigrationIssueSolved(bool isFixed) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setBool('isPkidMigrationIssueSolved', isFixed);
}

Future<void> setTheme(String theme) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.remove('theme');

prefs.setString('theme', theme);
}

Future<String?> getTheme() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();

return prefs.getString('theme');
}
30 changes: 30 additions & 0 deletions app/lib/widgets/theme_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:threebotlogin/services/shared_preference_service.dart';

class ThemeProvider with ChangeNotifier {
ThemeMode _themeMode;
ThemeProvider(this._themeMode);
ThemeMode get themeMode => _themeMode;

void toggleTheme() {
_themeMode =
_themeMode == ThemeMode.dark ? ThemeMode.light : ThemeMode.dark;
_saveTheme();
notifyListeners();
}

Future<void> _saveTheme() async {
await setTheme(_themeMode == ThemeMode.dark ? 'dark' : 'light');
}

Future<void> loadTheme() async {
String? savedTheme = await getTheme();
if (savedTheme != null) {
_themeMode = savedTheme == 'dark' ? ThemeMode.dark : ThemeMode.light;
} else {
_themeMode = ThemeMode.system;
}
notifyListeners();
}
}
12 changes: 6 additions & 6 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ packages:
dependency: "direct main"
description:
path: "packages/gridproxy_client"
ref: tfchain_graphql_hotfix
resolved-ref: "314f46728e43cb86f430cda6ba756d4be3fb6e07"
ref: tfchain_graphql
resolved-ref: "34c29c3d39530dae2843fbe3ad47307db6d28a23"
url: "https://github.com/codescalers/tfgrid-sdk-dart"
source: git
version: "1.0.0"
Expand Down Expand Up @@ -1260,8 +1260,8 @@ packages:
dependency: "direct main"
description:
path: "packages/stellar_client"
ref: tfchain_graphql_hotfix_2
resolved-ref: "563cc0297d79dc333157fe69a7540f0190ff3496"
ref: tfchain_graphql
resolved-ref: "34c29c3d39530dae2843fbe3ad47307db6d28a23"
url: "https://github.com/codescalers/tfgrid-sdk-dart"
source: git
version: "0.1.0"
Expand Down Expand Up @@ -1349,8 +1349,8 @@ packages:
dependency: "direct main"
description:
path: "packages/tfchain_client"
ref: tfchain_graphql_hotfix
resolved-ref: "314f46728e43cb86f430cda6ba756d4be3fb6e07"
ref: tfchain_graphql
resolved-ref: "34c29c3d39530dae2843fbe3ad47307db6d28a23"
url: "https://github.com/codescalers/tfgrid-sdk-dart"
source: git
version: "0.1.0"
Expand Down
6 changes: 3 additions & 3 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ dependencies:
tfchain_client:
git:
url: https://github.com/codescalers/tfgrid-sdk-dart
ref: tfchain_graphql_hotfix
ref: tfchain_graphql
path: packages/tfchain_client
stellar_client:
git:
url: https://github.com/codescalers/tfgrid-sdk-dart
ref: tfchain_graphql_hotfix_2
ref: tfchain_graphql
path: packages/stellar_client
gridproxy_client:
git:
url: https://github.com/codescalers/tfgrid-sdk-dart
ref: tfchain_graphql_hotfix
ref: tfchain_graphql
path: packages/gridproxy_client
shuftipro_onsite_sdk: ^1.0.5
flutter_svg: ^2.0.6
Expand Down

0 comments on commit fe85d38

Please sign in to comment.