diff --git a/packages/at_backupkey_flutter/lib/widgets/backup_key_widget.dart b/packages/at_backupkey_flutter/lib/widgets/backup_key_widget.dart index dda9db754..055129f6e 100644 --- a/packages/at_backupkey_flutter/lib/widgets/backup_key_widget.dart +++ b/packages/at_backupkey_flutter/lib/widgets/backup_key_widget.dart @@ -73,16 +73,12 @@ class BackupKeyWidget extends StatelessWidget { width: buttonWidth ?? 158.toWidth, height: buttonHeight ?? (50.toHeight), padding: EdgeInsets.symmetric(horizontal: 10.toWidth), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(30.toWidth), - color: buttonColor ?? Colors.black), + decoration: + BoxDecoration(borderRadius: BorderRadius.circular(30.toWidth), color: buttonColor ?? Colors.black), child: Center( child: Text(buttonText!, textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16.toFont, - color: Colors.white, - fontWeight: FontWeight.bold)), + style: TextStyle(fontSize: 16.toFont, color: Colors.white, fontWeight: FontWeight.bold)), ), ), ) @@ -107,16 +103,14 @@ class BackupKeyWidget extends StatelessWidget { children: [ Text( 'Error', - style: TextStyle( - fontWeight: FontWeight.bold, fontSize: 14.toFont), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14.toFont), ), Icon(Icons.sentiment_dissatisfied, size: 25.toFont) ], ), content: Text( 'Could not backup the key file', - style: - TextStyle(fontWeight: FontWeight.bold, fontSize: 14.toFont), + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14.toFont), ), actions: [ TextButton( @@ -142,10 +136,7 @@ class BackupKeyWidget extends StatelessWidget { return Dialog( child: Container( padding: const EdgeInsets.all(20), - width: - (Platform.isMacOS || Platform.isWindows || Platform.isLinux) - ? 600 - : null, + width: (Platform.isMacOS || Platform.isWindows || Platform.isLinux) ? 600 : null, child: Column( mainAxisSize: MainAxisSize.min, children: [ @@ -161,8 +152,7 @@ class BackupKeyWidget extends StatelessWidget { 'PLEASE SECURELY SAVE YOUR KEYS. WE DO NOT HAVE ACCESS TO THEM AND CANNOT CREATE A BACKUP OR RESET THEM.', targetShapeBorder: const CircleBorder(), disableMovingAnimation: true, - targetBorderRadius: - const BorderRadius.all(Radius.circular(40)), + targetBorderRadius: const BorderRadius.all(Radius.circular(40)), showArrow: false, targetPadding: const EdgeInsets.all(5), blurValue: 2, @@ -182,9 +172,8 @@ class BackupKeyWidget extends StatelessWidget { ShowCaseWidget.of(myContext!).startShowCase([key]); }, child: Container( - decoration: BoxDecoration( - color: Colors.grey.shade400, - borderRadius: BorderRadius.circular(50)), + decoration: + BoxDecoration(color: Colors.grey.shade400, borderRadius: BorderRadius.circular(50)), margin: const EdgeInsets.all(0), height: 20, width: 20, @@ -210,9 +199,8 @@ class BackupKeyWidget extends StatelessWidget { Row( children: [ TextButton( - child: const Text(Strings.backButtonTitle, - style: - TextStyle(fontWeight: FontWeight.bold)), + child: + const Text(Strings.backButtonTitle, style: TextStyle(fontWeight: FontWeight.bold)), onPressed: () async { var result = await onBackup(context); if (context.mounted) { @@ -224,8 +212,7 @@ class BackupKeyWidget extends StatelessWidget { }), const Spacer(), TextButton( - child: const Text(Strings.cancelButtonTitle, - style: TextStyle()), + child: const Text(Strings.cancelButtonTitle, style: TextStyle()), onPressed: () { Navigator.pop(context); }) @@ -276,20 +263,17 @@ class BackupKeyWidget extends StatelessWidget { String? dir = await getDownloadPath(); if (dir != null) { - String newPath = - "$dir/$atsign${Strings.backupKeyName}"; + String newPath = "$dir/$atsign${Strings.backupKeyName}"; debugPrint(newPath); try { if (await File(newPath).exists()) { if (context.mounted) { Navigator.of(context).pop(); - showSnackBar( - context: context, content: "File exists!"); + showSnackBar(context: context, content: "File exists!"); } } else { - final encryptedKeysFile = - await File(newPath).create(); + final encryptedKeysFile = await File(newPath).create(); var keyString = jsonEncode(aesEncryptedKeys); encryptedKeysFile.writeAsStringSync(keyString); if (context.mounted) { @@ -339,18 +323,15 @@ class BackupKeyWidget extends StatelessWidget { var size = MediaQuery.of(context).size; await Share.shareXFiles( [XFile(tempFilePath)], - sharePositionOrigin: - Rect.fromLTWH(0, 0, size.width, size.height / 2), + sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2), ).then((ShareResult shareResult) { - if (shareResult.status == ShareResultStatus.success) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('File saved successfully'))); + if (shareResult.status == ShareResultStatus.success && context.mounted) { + ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('File saved successfully'))); } }); } } else { - final path = await getSaveLocation( - suggestedName: '$atsign${Strings.backupKeyName}'); + final path = await getSaveLocation(suggestedName: '$atsign${Strings.backupKeyName}'); if (path == null) return; final file = XFile(tempFilePath); await file.saveTo(path.path); @@ -377,8 +358,7 @@ class BackupKeyWidget extends StatelessWidget { var directory = await path_provider.getApplicationSupportDirectory(); String path = directory.path.toString() + Platform.pathSeparator; - final encryptedKeysFile = - await File('$path$atsign${Strings.backupKeyName}').create(); + final encryptedKeysFile = await File('$path$atsign${Strings.backupKeyName}').create(); var keyString = jsonEncode(aesEncryptedKeys); encryptedKeysFile.writeAsStringSync(keyString); return encryptedKeysFile.path; @@ -387,9 +367,8 @@ class BackupKeyWidget extends StatelessWidget { var keyString = jsonEncode(aesEncryptedKeys); final List codeUnits = keyString.codeUnits; final Uint8List data = Uint8List.fromList(codeUnits); - String desktopPath = await FileSaver.instance.saveFile( - encryptedKeysFile, data, Strings.backupKeyExtension, - mimeType: MimeType.OTHER); + String desktopPath = await FileSaver.instance + .saveFile(encryptedKeysFile, data, Strings.backupKeyExtension, mimeType: MimeType.OTHER); return desktopPath; } } @@ -403,9 +382,8 @@ class BackupKeyWidget extends StatelessWidget { [XFile(path)], sharePositionOrigin: Rect.fromLTWH(0, 0, size.width, size.height / 2), ).then((ShareResult shareResult) { - if (shareResult.status == ShareResultStatus.success) { - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar(content: Text('File saved successfully'))); + if (shareResult.status == ShareResultStatus.success && context.mounted) { + ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('File saved successfully'))); } }); } diff --git a/packages/at_common_flutter/CHANGELOG.md b/packages/at_common_flutter/CHANGELOG.md index 679aebcc5..8140bd067 100644 --- a/packages/at_common_flutter/CHANGELOG.md +++ b/packages/at_common_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.14 +- **CHORE**: Addressed static analysis info and warning messages to improve code quality and reduce noise during analysis. +- **FIX**: Replace depreciated items with up-to-date-ones + ## 2.0.13: - **CHORE**: Major version increase of at_commons from ^3.0.55 to ^4.0.1 diff --git a/packages/at_common_flutter/example/lib/main.dart b/packages/at_common_flutter/example/lib/main.dart index e4b3ae7fe..b625f97f8 100644 --- a/packages/at_common_flutter/example/lib/main.dart +++ b/packages/at_common_flutter/example/lib/main.dart @@ -1,12 +1,11 @@ import 'dart:async'; import 'dart:developer'; +import 'package:at_common_flutter/at_common_flutter.dart'; import 'package:at_common_flutter/utils/text_styles.dart'; import 'package:flutter/material.dart'; -import 'package:at_common_flutter/at_common_flutter.dart'; -final StreamController updateThemeMode = - StreamController.broadcast(); +final StreamController updateThemeMode = StreamController.broadcast(); void main() { runApp(const MyApp()); @@ -57,7 +56,7 @@ class MyHomePage extends StatefulWidget { final String? title; @override - _MyHomePageState createState() => _MyHomePageState(); + State createState() => _MyHomePageState(); } class _MyHomePageState extends State { @@ -77,16 +76,12 @@ class _MyHomePageState extends State { showTitle: true, titleText: widget.title, titleTextStyle: CustomTextStyles.primaryBold18.copyWith( - color: Theme.of(context).brightness == Brightness.light - ? Colors.black - : Colors.white, + color: Theme.of(context).brightness == Brightness.light ? Colors.black : Colors.white, ), showLeadingIcon: true, leadingIcon: Icon( Icons.home_outlined, - color: Theme.of(context).brightness == Brightness.light - ? Colors.black - : Colors.white, + color: Theme.of(context).brightness == Brightness.light ? Colors.black : Colors.white, ), onTrailingIconPressed: () { log('Trailing icon of appbar pressed'); @@ -95,15 +90,11 @@ class _MyHomePageState extends State { trailingIcon: Center( child: IconButton( onPressed: () { - updateThemeMode.sink.add( - Theme.of(context).brightness == Brightness.light - ? ThemeMode.dark - : ThemeMode.light); + updateThemeMode.sink + .add(Theme.of(context).brightness == Brightness.light ? ThemeMode.dark : ThemeMode.light); }, icon: Icon( - Theme.of(context).brightness == Brightness.light - ? Icons.dark_mode_outlined - : Icons.light_mode_outlined, + Theme.of(context).brightness == Brightness.light ? Icons.dark_mode_outlined : Icons.light_mode_outlined, color: Theme.of(context).colorScheme.secondary, ), ), @@ -161,12 +152,8 @@ class _MyHomePageState extends State { onPressed: () { log('Custom button pressed'); }, - buttonColor: Theme.of(context).brightness == Brightness.light - ? Colors.black - : Colors.white, - fontColor: Theme.of(context).brightness == Brightness.light - ? Colors.white - : Colors.black, + buttonColor: Theme.of(context).brightness == Brightness.light ? Colors.black : Colors.white, + fontColor: Theme.of(context).brightness == Brightness.light ? Colors.white : Colors.black, ), ], ), diff --git a/packages/at_common_flutter/example/pubspec.yaml b/packages/at_common_flutter/example/pubspec.yaml index 9c790d737..0889a6da8 100644 --- a/packages/at_common_flutter/example/pubspec.yaml +++ b/packages/at_common_flutter/example/pubspec.yaml @@ -32,7 +32,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 + cupertino_icons: ^1.0.8 at_common_flutter: path: ../ @@ -41,7 +41,7 @@ dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^1.0.0 + flutter_lints: ^4.0.0 # For information on the generic Dart part of this file, see the diff --git a/packages/at_common_flutter/pubspec.yaml b/packages/at_common_flutter/pubspec.yaml index 332884260..f0e7b2b26 100644 --- a/packages/at_common_flutter/pubspec.yaml +++ b/packages/at_common_flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: at_common_flutter description: A Flutter package to provide common widgets used by other atPlatform Flutter packages. -version: 2.0.13 +version: 2.0.14 homepage: https://docs.atsign.com/ repository: https://github.com/atsign-foundation/at_widgets/tree/trunk/packages/at_common_flutter issue_tracker: https://github.com/atsign-foundation/at_widgets/issues @@ -17,8 +17,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.1 - mocktail: ^0.3.0 + flutter_lints: ^4.0.0 + mocktail: ^1.0.4 # For information on the generic Dart part of this file, see the diff --git a/packages/at_contacts_group_flutter/example/lib/main.dart b/packages/at_contacts_group_flutter/example/lib/main.dart index a565a4c7a..34c53cee4 100644 --- a/packages/at_contacts_group_flutter/example/lib/main.dart +++ b/packages/at_contacts_group_flutter/example/lib/main.dart @@ -1,13 +1,13 @@ import 'dart:async'; -import 'second_screen.dart'; -import 'package:flutter/material.dart'; +import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart' show AtOnboarding, AtOnboardingConfig, AtOnboardingResultStatus; -import 'package:path_provider/path_provider.dart' - show getApplicationSupportDirectory; -import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart' show getApplicationSupportDirectory; + +import 'second_screen.dart'; Future main() async { await AtEnv.load(); @@ -24,14 +24,13 @@ Future loadAtClientPreference() async { ..isLocalStoreRequired = true; } -final StreamController updateThemeMode = - StreamController.broadcast(); +final StreamController updateThemeMode = StreamController.broadcast(); class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { @@ -51,16 +50,14 @@ class _MyAppState extends State { theme: ThemeData().copyWith( brightness: Brightness.light, primaryColor: const Color(0xFFf4533d), - colorScheme: ThemeData.light().colorScheme.copyWith( - primary: const Color(0xFFf4533d), surface: Colors.white), + colorScheme: + ThemeData.light().colorScheme.copyWith(primary: const Color(0xFFf4533d), surface: Colors.white), scaffoldBackgroundColor: Colors.white, ), darkTheme: ThemeData().copyWith( brightness: Brightness.dark, primaryColor: Colors.blue, - colorScheme: ThemeData.dark() - .colorScheme - .copyWith(primary: Colors.blue, surface: Colors.white), + colorScheme: ThemeData.dark().colorScheme.copyWith(primary: Colors.blue, surface: Colors.white), scaffoldBackgroundColor: Colors.grey[850], ), themeMode: themeMode, @@ -70,9 +67,7 @@ class _MyAppState extends State { actions: [ IconButton( onPressed: () { - updateThemeMode.sink.add(themeMode == ThemeMode.light - ? ThemeMode.dark - : ThemeMode.light); + updateThemeMode.sink.add(themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light); }, icon: Icon( Theme.of(context).brightness == Brightness.light @@ -93,32 +88,31 @@ class _MyAppState extends State { setState(() { atClientPreference = preference; }); - final result = await AtOnboarding.onboard( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); - switch (result.status) { - case AtOnboardingResultStatus.success: - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => const SecondScreen())); - break; - case AtOnboardingResultStatus.error: - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - backgroundColor: Colors.red, - content: Text('An error has occurred'), - ), - ); - break; - case AtOnboardingResultStatus.cancel: - break; + if (context.mounted) { + final result = await AtOnboarding.onboard( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + switch (result.status) { + case AtOnboardingResultStatus.success: + Navigator.push(context, MaterialPageRoute(builder: (_) => const SecondScreen())); + break; + case AtOnboardingResultStatus.error: + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: Colors.red, + content: Text('An error has occurred'), + ), + ); + break; + case AtOnboardingResultStatus.cancel: + break; + } } }, child: const Text('Onboard an @sign'), @@ -128,15 +122,17 @@ class _MyAppState extends State { onPressed: () async { var preference = await futurePreference; atClientPreference = preference; - AtOnboarding.reset( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); + if (context.mounted) { + AtOnboarding.reset( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + } }, child: const Text('Reset'), ), diff --git a/packages/at_contacts_group_flutter/example/lib/second_screen.dart b/packages/at_contacts_group_flutter/example/lib/second_screen.dart index 23f902ea2..2f81b638d 100644 --- a/packages/at_contacts_group_flutter/example/lib/second_screen.dart +++ b/packages/at_contacts_group_flutter/example/lib/second_screen.dart @@ -1,15 +1,15 @@ import 'package:at_app_flutter/at_app_flutter.dart'; +import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_contacts_flutter/at_contacts_flutter.dart'; import 'package:at_contacts_group_flutter/at_contacts_group_flutter.dart'; import 'package:at_contacts_group_flutter/screens/group_contact_view/group_contact_view.dart'; import 'package:flutter/material.dart'; -import 'package:at_client_mobile/at_client_mobile.dart'; class SecondScreen extends StatefulWidget { const SecondScreen({Key? key}) : super(key: key); @override - _SecondScreenState createState() => _SecondScreenState(); + State createState() => _SecondScreenState(); } class _SecondScreenState extends State { diff --git a/packages/at_contacts_group_flutter/example/pubspec.yaml b/packages/at_contacts_group_flutter/example/pubspec.yaml index b89738ef0..43d1ebd5a 100644 --- a/packages/at_contacts_group_flutter/example/pubspec.yaml +++ b/packages/at_contacts_group_flutter/example/pubspec.yaml @@ -32,6 +32,8 @@ dependencies: at_app_flutter: ^5.2.0 at_backupkey_flutter: ^4.0.10 + at_client_mobile: ^3.2.15 + at_contacts_flutter: ^4.0.14 at_contacts_group_flutter: # When depending on this package from a real application you should use: # at_contacts_group_flutter: ^x.y.z @@ -45,6 +47,7 @@ dependencies: cupertino_icons: ^1.0.6 flutter: sdk: flutter + path_provider: ^2.1.3 dev_dependencies: # The "flutter_lints" package below contains a set of recommended lints to diff --git a/packages/at_events_flutter/example/lib/main.dart b/packages/at_events_flutter/example/lib/main.dart index aa37b151f..fbb08b11e 100644 --- a/packages/at_events_flutter/example/lib/main.dart +++ b/packages/at_events_flutter/example/lib/main.dart @@ -1,13 +1,12 @@ import 'dart:async'; -import 'package:at_events_flutter_example/second_screen.dart'; -import 'package:flutter/material.dart'; +import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; import 'package:at_client_mobile/at_client_mobile.dart'; +import 'package:at_events_flutter_example/second_screen.dart'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart' show AtOnboarding, AtOnboardingConfig, AtOnboardingResultStatus; -import 'package:path_provider/path_provider.dart' - show getApplicationSupportDirectory; -import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart' show getApplicationSupportDirectory; Future main() async { await AtEnv.load(); @@ -17,22 +16,20 @@ Future main() async { Future loadAtClientPreference() async { var dir = await getApplicationSupportDirectory(); return AtClientPreference() - ..rootDomain = AtEnv.rootDomain - ..namespace = AtEnv.appNamespace - ..hiveStoragePath = dir.path - ..commitLogPath = dir.path - ..isLocalStoreRequired = true - ; + ..rootDomain = AtEnv.rootDomain + ..namespace = AtEnv.appNamespace + ..hiveStoragePath = dir.path + ..commitLogPath = dir.path + ..isLocalStoreRequired = true; } -final StreamController updateThemeMode = - StreamController.broadcast(); +final StreamController updateThemeMode = StreamController.broadcast(); class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { @@ -53,16 +50,14 @@ class _MyAppState extends State { theme: ThemeData().copyWith( brightness: Brightness.light, primaryColor: const Color(0xFFf4533d), - colorScheme: ThemeData.light().colorScheme.copyWith( - primary: const Color(0xFFf4533d), surface: Colors.white), + colorScheme: + ThemeData.light().colorScheme.copyWith(primary: const Color(0xFFf4533d), surface: Colors.white), scaffoldBackgroundColor: Colors.white, ), darkTheme: ThemeData().copyWith( brightness: Brightness.dark, primaryColor: Colors.blue, - colorScheme: ThemeData.dark() - .colorScheme - .copyWith(primary: Colors.blue, surface: Colors.grey[850]), + colorScheme: ThemeData.dark().colorScheme.copyWith(primary: Colors.blue, surface: Colors.grey[850]), scaffoldBackgroundColor: Colors.grey[850], ), themeMode: themeMode, @@ -72,9 +67,7 @@ class _MyAppState extends State { actions: [ IconButton( onPressed: () { - updateThemeMode.sink.add(themeMode == ThemeMode.light - ? ThemeMode.dark - : ThemeMode.light); + updateThemeMode.sink.add(themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light); }, icon: Icon( Theme.of(context).brightness == Brightness.light @@ -95,32 +88,31 @@ class _MyAppState extends State { setState(() { atClientPreference = preference; }); - final result = await AtOnboarding.onboard( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); - switch (result.status) { - case AtOnboardingResultStatus.success: - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => const SecondScreen())); - break; - case AtOnboardingResultStatus.error: - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - backgroundColor: Colors.red, - content: Text('An error has occurred'), - ), - ); - break; - case AtOnboardingResultStatus.cancel: - break; + if (context.mounted) { + final result = await AtOnboarding.onboard( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + switch (result.status) { + case AtOnboardingResultStatus.success: + Navigator.push(context, MaterialPageRoute(builder: (_) => const SecondScreen())); + break; + case AtOnboardingResultStatus.error: + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: Colors.red, + content: Text('An error has occurred'), + ), + ); + break; + case AtOnboardingResultStatus.cancel: + break; + } } }, child: const Text('Onboard an atSign'), @@ -130,15 +122,17 @@ class _MyAppState extends State { onPressed: () async { var preference = await futurePreference; atClientPreference = preference; - AtOnboarding.reset( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); + if (context.mounted) { + AtOnboarding.reset( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + } }, child: const Text('Reset'), ), diff --git a/packages/at_events_flutter/example/lib/second_screen.dart b/packages/at_events_flutter/example/lib/second_screen.dart index 926f1f218..2c7e78083 100644 --- a/packages/at_events_flutter/example/lib/second_screen.dart +++ b/packages/at_events_flutter/example/lib/second_screen.dart @@ -1,15 +1,15 @@ +import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_events_flutter/at_events_flutter.dart'; import 'package:flutter/material.dart'; -import 'package:at_client_mobile/at_client_mobile.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart' show dotenv; import 'main.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart' show dotenv; class SecondScreen extends StatefulWidget { const SecondScreen({Key? key}) : super(key: key); @override - _SecondScreenState createState() => _SecondScreenState(); + State createState() => _SecondScreenState(); } class _SecondScreenState extends State { @@ -43,9 +43,9 @@ class _SecondScreenState extends State { } } - void updateEvents(List _events) { + void updateEvents(List events) { setState(() { - events = _events; + events = events; }); } @@ -75,13 +75,11 @@ class _SecondScreenState extends State { ), TextButton( onPressed: () { - bottomSheet(CreateEvent(atClientManager), - MediaQuery.of(context).size.height * 0.9); + bottomSheet(CreateEvent(atClientManager), MediaQuery.of(context).size.height * 0.9); }, child: const SizedBox( height: 40, - child: - Text('Create event', style: TextStyle(color: Colors.black)), + child: Text('Create event', style: TextStyle(color: Colors.black)), ), ), const SizedBox( @@ -92,30 +90,19 @@ class _SecondScreenState extends State { itemBuilder: (BuildContext context, int index) { return InkWell( onTap: () { - HomeEventService().onEventModelTap( - events[index].eventNotificationModel!, - events[index].haveResponded); + HomeEventService() + .onEventModelTap(events[index].eventNotificationModel!, events[index].haveResponded); }, child: DisplayTile( - atsignCreator: - events[index].eventNotificationModel!.atsignCreator, - number: events[index] - .eventNotificationModel! - .group! - .members! - .length, - title: 'Event - ' + - events[index].eventNotificationModel!.title!, - subTitle: HomeEventService() - .getSubTitle(events[index].eventNotificationModel!), - semiTitle: HomeEventService().getSemiTitle( - events[index].eventNotificationModel!, - events[index].haveResponded), - showRetry: - HomeEventService().calculateShowRetry(events[index]), + atsignCreator: events[index].eventNotificationModel!.atsignCreator, + number: events[index].eventNotificationModel!.group!.members!.length, + title: 'Event - ${events[index].eventNotificationModel!.title!}', + subTitle: HomeEventService().getSubTitle(events[index].eventNotificationModel!), + semiTitle: HomeEventService() + .getSemiTitle(events[index].eventNotificationModel!, events[index].haveResponded), + showRetry: HomeEventService().calculateShowRetry(events[index]), onRetryTapped: () { - HomeEventService().onEventModelTap( - events[index].eventNotificationModel!, false); + HomeEventService().onEventModelTap(events[index].eventNotificationModel!, false); }, ), ); diff --git a/packages/at_events_flutter/example/pubspec.yaml b/packages/at_events_flutter/example/pubspec.yaml index c6e28f9df..b528b1c0d 100644 --- a/packages/at_events_flutter/example/pubspec.yaml +++ b/packages/at_events_flutter/example/pubspec.yaml @@ -28,6 +28,7 @@ environment: # versions available, run `flutter pub outdated`. dependencies: at_app_flutter: ^5.2.0 + at_client_mobile: ^3.2.15 at_events_flutter: # When depending on this package from a real application you should use: # at_events_flutter: ^x.y.z @@ -42,6 +43,8 @@ dependencies: cupertino_icons: ^1.0.6 flutter: sdk: flutter + flutter_dotenv: ^5.1.0 + path_provider: ^2.1.3 dev_dependencies: # The "flutter_lints" package below contains a set of recommended lints to diff --git a/packages/at_location_flutter/example/lib/main.dart b/packages/at_location_flutter/example/lib/main.dart index dd0597877..58898110a 100644 --- a/packages/at_location_flutter/example/lib/main.dart +++ b/packages/at_location_flutter/example/lib/main.dart @@ -1,11 +1,12 @@ import 'dart:async'; -import 'package:flutter/material.dart'; + +import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart' show AtOnboarding, AtOnboardingConfig, AtOnboardingResultStatus; -import 'package:path_provider/path_provider.dart' - show getApplicationSupportDirectory; -import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart' show getApplicationSupportDirectory; + import 'second_screen.dart'; Future main() async { @@ -26,14 +27,13 @@ Future loadAtClientPreference() async { ; } -final StreamController updateThemeMode = - StreamController.broadcast(); +final StreamController updateThemeMode = StreamController.broadcast(); class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { @@ -76,9 +76,7 @@ class _MyAppState extends State { actions: [ IconButton( onPressed: () { - updateThemeMode.sink.add(themeMode == ThemeMode.light - ? ThemeMode.dark - : ThemeMode.light); + updateThemeMode.sink.add(themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light); }, icon: Icon( Theme.of(context).brightness == Brightness.light @@ -99,32 +97,31 @@ class _MyAppState extends State { setState(() { atClientPreference = preference; }); - final result = await AtOnboarding.onboard( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); - switch (result.status) { - case AtOnboardingResultStatus.success: - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => const SecondScreen())); - break; - case AtOnboardingResultStatus.error: - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - backgroundColor: Colors.red, - content: Text('An error has occurred'), - ), - ); - break; - case AtOnboardingResultStatus.cancel: - break; + if (context.mounted) { + final result = await AtOnboarding.onboard( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + switch (result.status) { + case AtOnboardingResultStatus.success: + Navigator.push(context, MaterialPageRoute(builder: (_) => const SecondScreen())); + break; + case AtOnboardingResultStatus.error: + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: Colors.red, + content: Text('An error has occurred'), + ), + ); + break; + case AtOnboardingResultStatus.cancel: + break; + } } }, child: const Text('Onboard an atSign'), @@ -134,15 +131,17 @@ class _MyAppState extends State { onPressed: () async { var preference = await futurePreference; atClientPreference = preference; - AtOnboarding.reset( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); + if (context.mounted) { + AtOnboarding.reset( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + } }, child: const Text('Reset'), ), diff --git a/packages/at_location_flutter/example/lib/second_screen.dart b/packages/at_location_flutter/example/lib/second_screen.dart index 367eac5db..84e137b9f 100644 --- a/packages/at_location_flutter/example/lib/second_screen.dart +++ b/packages/at_location_flutter/example/lib/second_screen.dart @@ -1,20 +1,21 @@ +import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_common_flutter/services/size_config.dart'; import 'package:at_location_flutter/at_location_flutter.dart'; import 'package:at_location_flutter/common_components/custom_toast.dart'; import 'package:at_location_flutter/location_modal/key_location_model.dart'; import 'package:at_location_flutter/service/key_stream_service.dart'; -import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_lookup/at_lookup.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart' show dotenv; import 'package:latlong2/latlong.dart'; + import 'main.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart' show dotenv; class SecondScreen extends StatefulWidget { const SecondScreen({Key? key}) : super(key: key); @override - _SecondScreenState createState() => _SecondScreenState(); + State createState() => _SecondScreenState(); } class _SecondScreenState extends State { @@ -99,10 +100,11 @@ class _SecondScreenState extends State { ElevatedButton( onPressed: () async { var result = await checkAtsign(); - if (!result) { + if (!result && context.mounted) { CustomToast().show('Atsign not valid', context); return; } + if (!result) return; await sendShareLocationNotification(receiver!, 30); }, child: const Text('Send Location '), @@ -110,10 +112,11 @@ class _SecondScreenState extends State { ElevatedButton( onPressed: () async { var result = await checkAtsign(); - if (!result) { + if (!result && context.mounted) { CustomToast().show('Atsign not valid', context); return; } + if (!result) return; await sendRequestLocationNotification(receiver!); }, child: const Text('Request Location'), @@ -126,27 +129,28 @@ class _SecondScreenState extends State { ElevatedButton( onPressed: () async { var result = await checkAtsign(); - if (!result) { - CustomToast().show('Atsign not valid', context); - return; + if (context.mounted) { + if (!result) { + CustomToast().show('Atsign not valid', context); + return; + } + await Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) => AtLocationFlutterPlugin( + [receiver], + calculateETA: true, + addCurrentUserMarker: true, + // etaFrom: LatLng(44, -112), + // textForCenter: 'Final', + ), + )); } - await Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext context) => AtLocationFlutterPlugin( - [receiver], - calculateETA: true, - addCurrentUserMarker: true, - // etaFrom: LatLng(44, -112), - // textForCenter: 'Final', - ), - )); }, child: const Text('Track Location '), ), ElevatedButton( onPressed: () async { await Navigator.of(context).push(MaterialPageRoute( - builder: (BuildContext context) => - showLocation(UniqueKey(), mapController, locationList: [ + builder: (BuildContext context) => showLocation(UniqueKey(), mapController, locationList: [ const LatLng(30, 45), const LatLng(40, 45), ]), @@ -170,8 +174,7 @@ class _SecondScreenState extends State { padding: const EdgeInsets.all(8.0), child: StreamBuilder( stream: KeyStreamService().atNotificationsStream, - builder: (context, - AsyncSnapshot> snapshot) { + builder: (context, AsyncSnapshot> snapshot) { if (snapshot.connectionState == ConnectionState.active) { if (snapshot.hasError) { return const Text('error'); @@ -181,11 +184,8 @@ class _SecondScreenState extends State { : const Text('No Data'); } } else { - if (KeyStreamService() - .allLocationNotifications - .isNotEmpty) { - return renderNotifications( - KeyStreamService().allLocationNotifications); + if (KeyStreamService().allLocationNotifications.isNotEmpty) { + return renderNotifications(KeyStreamService().allLocationNotifications); } return const Text('No Data'); } @@ -197,13 +197,13 @@ class _SecondScreenState extends State { ); } - Widget renderNotifications(List _data) { + Widget renderNotifications(List data) { return Column( - children: _data.map((notification) { + children: data.map((notification) { return Padding( padding: const EdgeInsets.all(14.0), child: Text( - '${_data.indexOf(notification) + 1}. ${notification.locationNotificationModel!.key}', + '${data.indexOf(notification) + 1}. ${notification.locationNotificationModel!.key}', style: const TextStyle(fontSize: 16), textAlign: TextAlign.left, ), @@ -215,7 +215,7 @@ class _SecondScreenState extends State { if (receiver == null) { return false; } else if (!receiver!.contains('@')) { - receiver = '@' + receiver!; + receiver = '@${receiver!}'; } var checkPresence = // ignore: deprecated_member_use diff --git a/packages/at_location_flutter/example/pubspec.yaml b/packages/at_location_flutter/example/pubspec.yaml index 795241fba..241a2308c 100644 --- a/packages/at_location_flutter/example/pubspec.yaml +++ b/packages/at_location_flutter/example/pubspec.yaml @@ -28,6 +28,7 @@ environment: # versions available, run `flutter pub outdated`. dependencies: at_app_flutter: ^5.2.0 + at_client_mobile: ^3.2.15 at_location_flutter: # When depending on this package from a real application you should use: # at_location_flutter: ^x.y.z @@ -43,6 +44,10 @@ dependencies: flutter: sdk: flutter latlong2: ^0.9.0 + path_provider: ^2.1.3 + at_common_flutter: ^2.0.13 + at_lookup: ^3.0.47 + flutter_dotenv: ^5.1.0 dev_dependencies: # The "flutter_lints" package below contains a set of recommended lints to diff --git a/packages/at_location_flutter/pubspec.yaml b/packages/at_location_flutter/pubspec.yaml index 2f9ba589f..7c05cd71f 100644 --- a/packages/at_location_flutter/pubspec.yaml +++ b/packages/at_location_flutter/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: async: ^2.11.0 at_client: ^3.0.72 at_client_mobile: ^3.2.12 - at_common_flutter: ^2.0.12 + at_common_flutter: ^2.0.13 at_commons: ^4.0.1 at_contact: ^3.0.8 at_contacts_flutter: ^4.0.14 diff --git a/packages/at_login_flutter/example/ios/Flutter/AppFrameworkInfo.plist b/packages/at_login_flutter/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105d..7c5696400 100644 --- a/packages/at_login_flutter/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/at_login_flutter/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/packages/at_login_flutter/example/ios/Podfile b/packages/at_login_flutter/example/ios/Podfile index 88359b225..279576f38 100644 --- a/packages/at_login_flutter/example/ios/Podfile +++ b/packages/at_login_flutter/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '11.0' +# platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/packages/at_login_flutter/example/ios/Podfile.lock b/packages/at_login_flutter/example/ios/Podfile.lock index 0c2c3c17d..f10337b40 100644 --- a/packages/at_login_flutter/example/ios/Podfile.lock +++ b/packages/at_login_flutter/example/ios/Podfile.lock @@ -1,123 +1,165 @@ PODS: - at_backupkey_flutter (0.0.1): - Flutter + - at_file_saver (0.0.1): + - Flutter - at_onboarding_flutter (0.0.1): - Flutter - - DKImagePickerController/Core (4.3.2): + - biometric_storage (0.0.1): + - Flutter + - device_info_plus (0.0.1): + - Flutter + - DKImagePickerController/Core (4.3.9): - DKImagePickerController/ImageDataManager - DKImagePickerController/Resource - - DKImagePickerController/ImageDataManager (4.3.2) - - DKImagePickerController/PhotoGallery (4.3.2): + - DKImagePickerController/ImageDataManager (4.3.9) + - DKImagePickerController/PhotoGallery (4.3.9): - DKImagePickerController/Core - DKPhotoGallery - - DKImagePickerController/Resource (4.3.2) - - DKPhotoGallery (0.0.17): - - DKPhotoGallery/Core (= 0.0.17) - - DKPhotoGallery/Model (= 0.0.17) - - DKPhotoGallery/Preview (= 0.0.17) - - DKPhotoGallery/Resource (= 0.0.17) + - DKImagePickerController/Resource (4.3.9) + - DKPhotoGallery (0.0.19): + - DKPhotoGallery/Core (= 0.0.19) + - DKPhotoGallery/Model (= 0.0.19) + - DKPhotoGallery/Preview (= 0.0.19) + - DKPhotoGallery/Resource (= 0.0.19) - SDWebImage - SwiftyGif - - DKPhotoGallery/Core (0.0.17): + - DKPhotoGallery/Core (0.0.19): - DKPhotoGallery/Model - DKPhotoGallery/Preview - SDWebImage - SwiftyGif - - DKPhotoGallery/Model (0.0.17): + - DKPhotoGallery/Model (0.0.19): - SDWebImage - SwiftyGif - - DKPhotoGallery/Preview (0.0.17): + - DKPhotoGallery/Preview (0.0.19): - DKPhotoGallery/Model - DKPhotoGallery/Resource - SDWebImage - SwiftyGif - - DKPhotoGallery/Resource (0.0.17): + - DKPhotoGallery/Resource (0.0.19): - SDWebImage - SwiftyGif - file_picker (0.0.1): - DKImagePickerController/PhotoGallery - Flutter + - file_selector_ios (0.0.1): + - Flutter - Flutter (1.0.0) - flutter_keychain (0.0.1): - Flutter - - flutter_qr_reader (0.0.1): + - MTBBarcodeScanner (5.0.11) + - package_info_plus (0.4.5): + - Flutter + - path_provider_foundation (0.0.1): + - Flutter + - FlutterMacOS + - permission_handler_apple (9.3.0): - Flutter - - path_provider (0.0.1): + - qr_code_scanner (0.2.0): - Flutter - - "permission_handler (5.1.0+2)": + - MTBBarcodeScanner + - SDWebImage (5.19.2): + - SDWebImage/Core (= 5.19.2) + - SDWebImage/Core (5.19.2) + - share_plus (0.0.1): - Flutter - - SDWebImage (5.11.0): - - SDWebImage/Core (= 5.11.0) - - SDWebImage/Core (5.11.0) - - share (0.0.1): + - shared_preferences_foundation (0.0.1): - Flutter - - SwiftyGif (5.4.0) - - url_launcher (0.0.1): + - FlutterMacOS + - SwiftyGif (5.4.5) + - url_launcher_ios (0.0.1): - Flutter - - webview_flutter (0.0.1): + - webview_flutter_wkwebview (0.0.1): - Flutter DEPENDENCIES: - at_backupkey_flutter (from `.symlinks/plugins/at_backupkey_flutter/ios`) + - at_file_saver (from `.symlinks/plugins/at_file_saver/ios`) - at_onboarding_flutter (from `.symlinks/plugins/at_onboarding_flutter/ios`) + - biometric_storage (from `.symlinks/plugins/biometric_storage/ios`) + - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) + - file_selector_ios (from `.symlinks/plugins/file_selector_ios/ios`) - Flutter (from `Flutter`) - flutter_keychain (from `.symlinks/plugins/flutter_keychain/ios`) - - flutter_qr_reader (from `.symlinks/plugins/flutter_qr_reader/ios`) - - path_provider (from `.symlinks/plugins/path_provider/ios`) - - permission_handler (from `.symlinks/plugins/permission_handler/ios`) - - share (from `.symlinks/plugins/share/ios`) - - url_launcher (from `.symlinks/plugins/url_launcher/ios`) - - webview_flutter (from `.symlinks/plugins/webview_flutter/ios`) + - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) + - 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`) + - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) + - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) SPEC REPOS: trunk: - DKImagePickerController - DKPhotoGallery + - MTBBarcodeScanner - SDWebImage - SwiftyGif EXTERNAL SOURCES: at_backupkey_flutter: :path: ".symlinks/plugins/at_backupkey_flutter/ios" + at_file_saver: + :path: ".symlinks/plugins/at_file_saver/ios" at_onboarding_flutter: :path: ".symlinks/plugins/at_onboarding_flutter/ios" + biometric_storage: + :path: ".symlinks/plugins/biometric_storage/ios" + device_info_plus: + :path: ".symlinks/plugins/device_info_plus/ios" file_picker: :path: ".symlinks/plugins/file_picker/ios" + file_selector_ios: + :path: ".symlinks/plugins/file_selector_ios/ios" Flutter: :path: Flutter flutter_keychain: :path: ".symlinks/plugins/flutter_keychain/ios" - flutter_qr_reader: - :path: ".symlinks/plugins/flutter_qr_reader/ios" - path_provider: - :path: ".symlinks/plugins/path_provider/ios" - permission_handler: - :path: ".symlinks/plugins/permission_handler/ios" - share: - :path: ".symlinks/plugins/share/ios" - url_launcher: - :path: ".symlinks/plugins/url_launcher/ios" - webview_flutter: - :path: ".symlinks/plugins/webview_flutter/ios" + package_info_plus: + :path: ".symlinks/plugins/package_info_plus/ios" + path_provider_foundation: + :path: ".symlinks/plugins/path_provider_foundation/darwin" + permission_handler_apple: + :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" + url_launcher_ios: + :path: ".symlinks/plugins/url_launcher_ios/ios" + webview_flutter_wkwebview: + :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" SPEC CHECKSUMS: at_backupkey_flutter: 2fc3d01138175e41bce8b574387a47544c53e01b + at_file_saver: c0e052c72d8c0296318bd70f2ae7f510887014ce at_onboarding_flutter: e8219b6d0bfb236d3837ec3528871aebdcc56e8d - DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d - DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 - file_picker: 3e6c3790de664ccf9b882732d9db5eaf6b8d4eb1 - Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a + biometric_storage: 1400f1382af3a4cc2bf05340e13c3d8de873ceb9 + device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6 + DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c + DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60 + file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de + file_selector_ios: f0670c1064a8c8450e38145d8043160105d0b97c + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_keychain: 01aabf894ffe8b01adfda1d9df21c210c1b4b452 - flutter_qr_reader: d930dde3b2cfe2b3d0bb7d66e5ff3e514300a5e5 - path_provider: d1e9807085df1f9cc9318206cd649dc0b76be3de - permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0 - SDWebImage: 7acbb57630ac7db4a495547fb73916ff3e432f6b - share: 0b2c3e82132f5888bccca3351c504d0003b3b410 - SwiftyGif: 5d4af95df24caf1c570dbbcb32a3b8a0763bc6d7 - url_launcher: b6e016d912f04be9f5bf6e8e82dc599b7ba59649 - webview_flutter: 5fb4def2bbd4339889ee14d045b605cefc5bc232 + MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb + package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85 + path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 + permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 + qr_code_scanner: bb67d64904c3b9658ada8c402e8b4d406d5d796e + SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a + share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5 + shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 + SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 + url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe + webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36 -PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c +PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 -COCOAPODS: 1.10.1 +COCOAPODS: 1.14.3 diff --git a/packages/at_login_flutter/example/ios/Runner.xcodeproj/project.pbxproj b/packages/at_login_flutter/example/ios/Runner.xcodeproj/project.pbxproj index 01440b2b3..2899902db 100644 --- a/packages/at_login_flutter/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/at_login_flutter/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -140,6 +140,7 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 8A387BD48CA4CA451DBA819C /* [CP] Embed Pods Frameworks */, + 92E3514F39A21C3882865604 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -156,7 +157,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -200,10 +201,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -251,8 +254,26 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 92E3514F39A21C3882865604 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -340,7 +361,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -358,7 +379,10 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.atsign.atLoginExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -414,7 +438,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -463,7 +487,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -482,7 +506,10 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.atsign.atLoginExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -501,7 +528,10 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.atsign.atLoginExample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/packages/at_login_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/at_login_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140cfd..e67b2808a 100644 --- a/packages/at_login_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/at_login_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ { width: SizeConfig().screenWidth, child: Center( child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - ColorConstants.buttonHighLightColor!)), + valueColor: AlwaysStoppedAnimation(ColorConstants.buttonHighLightColor!)), ), ) : SizedBox() @@ -224,9 +224,7 @@ class _AtLoginWidgetState extends State { var cameraStatus = await Permission.camera.status; _logger.info("camera status => $cameraStatus"); - if (cameraStatus.isRestricted || - cameraStatus.isDenied || - cameraStatus.isPermanentlyDenied) { + if (cameraStatus.isRestricted || cameraStatus.isDenied || cameraStatus.isPermanentlyDenied) { await askPermissions(Permission.camera); } else if (cameraStatus.isGranted) { setState(() { @@ -269,11 +267,7 @@ class _AtLoginWidgetState extends State { _currentAtsign = _atLoginService.formatAtSign(jsonMap['atsign'])!; var isPaired = await _atLoginService.atsignIsPaired(_currentAtsign); if (isPaired) { - var message = Strings.loginRequest + - ' for ' + - _currentAtsign + - ' from ' + - requestorUrl; + var message = Strings.loginRequest + ' for ' + _currentAtsign + ' from ' + requestorUrl; _atLoginObj.requestorUrl = requestorUrl; _atLoginObj.atsign = _currentAtsign; _atLoginObj.challenge = challenge; @@ -325,7 +319,7 @@ class _AtLoginWidgetState extends State { return AlertDialog( content: Text(message, style: CustomTextStyles.fontR20primary), actions: [ - ButtonBar( + OverflowBar( children: [ ElevatedButton( child: const Text(Strings.loginDenied), @@ -374,7 +368,7 @@ class _AtLoginWidgetState extends State { return AlertDialog( content: Text(message, style: CustomTextStyles.fontR20primary), actions: [ - ButtonBar( + OverflowBar( children: [ ElevatedButton( child: const Text(Strings.notPairAtsign), diff --git a/packages/at_notify_flutter/example/lib/main.dart b/packages/at_notify_flutter/example/lib/main.dart index c3bc0dbf8..40c225f66 100644 --- a/packages/at_notify_flutter/example/lib/main.dart +++ b/packages/at_notify_flutter/example/lib/main.dart @@ -1,13 +1,12 @@ import 'dart:async'; -import 'package:at_notify_flutter_example/second_screen.dart'; -import 'package:flutter/material.dart'; +import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; import 'package:at_client_mobile/at_client_mobile.dart'; +import 'package:at_notify_flutter_example/second_screen.dart'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart' show AtOnboarding, AtOnboardingConfig, AtOnboardingResultStatus; -import 'package:path_provider/path_provider.dart' - show getApplicationSupportDirectory; -import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart' show getApplicationSupportDirectory; Future main() async { await AtEnv.load(); @@ -24,14 +23,13 @@ Future loadAtClientPreference() async { ..isLocalStoreRequired = true; } -final StreamController updateThemeMode = - StreamController.broadcast(); +final StreamController updateThemeMode = StreamController.broadcast(); class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { @@ -72,9 +70,7 @@ class _MyAppState extends State { actions: [ IconButton( onPressed: () { - updateThemeMode.sink.add(themeMode == ThemeMode.light - ? ThemeMode.dark - : ThemeMode.light); + updateThemeMode.sink.add(themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light); }, icon: Icon( Theme.of(context).brightness == Brightness.light @@ -95,32 +91,31 @@ class _MyAppState extends State { setState(() { atClientPreference = preference; }); - final result = await AtOnboarding.onboard( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); - switch (result.status) { - case AtOnboardingResultStatus.success: - Navigator.push( - context, - MaterialPageRoute( - builder: (_) => const SecondScreen())); - break; - case AtOnboardingResultStatus.error: - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - backgroundColor: Colors.red, - content: Text('An error has occurred'), - ), - ); - break; - case AtOnboardingResultStatus.cancel: - break; + if (context.mounted) { + final result = await AtOnboarding.onboard( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + switch (result.status) { + case AtOnboardingResultStatus.success: + Navigator.push(context, MaterialPageRoute(builder: (_) => const SecondScreen())); + break; + case AtOnboardingResultStatus.error: + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: Colors.red, + content: Text('An error has occurred'), + ), + ); + break; + case AtOnboardingResultStatus.cancel: + break; + } } }, child: const Text('Onboard an atSign'), @@ -130,15 +125,17 @@ class _MyAppState extends State { onPressed: () async { var preference = await futurePreference; atClientPreference = preference; - AtOnboarding.reset( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); + if (context.mounted) { + AtOnboarding.reset( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + } }, child: const Text('Reset'), ), diff --git a/packages/at_notify_flutter/example/lib/second_screen.dart b/packages/at_notify_flutter/example/lib/second_screen.dart index d08c7b682..b1a2f1043 100644 --- a/packages/at_notify_flutter/example/lib/second_screen.dart +++ b/packages/at_notify_flutter/example/lib/second_screen.dart @@ -1,12 +1,11 @@ import 'package:at_app_flutter/at_app_flutter.dart'; -import 'package:flutter/material.dart'; import 'package:at_client_mobile/at_client_mobile.dart'; +import 'package:at_lookup/at_lookup.dart'; import 'package:at_notify_flutter/screens/notify_screen.dart'; import 'package:at_notify_flutter/services/notify_service.dart'; import 'package:at_notify_flutter/utils/init_notify_service.dart'; import 'package:at_notify_flutter/utils/notify_utils.dart'; - -import 'package:at_lookup/at_lookup.dart'; +import 'package:flutter/material.dart'; import 'main.dart'; @@ -15,7 +14,7 @@ class SecondScreen extends StatefulWidget { const SecondScreen({Key? key}) : super(key: key); @override - _SecondScreenState createState() => _SecondScreenState(); + State createState() => _SecondScreenState(); } class _SecondScreenState extends State { @@ -55,8 +54,7 @@ class _SecondScreenState extends State { ), TextField( controller: atSignController, - decoration: const InputDecoration( - border: OutlineInputBorder(), hintText: '@atSign'), + decoration: const InputDecoration(border: OutlineInputBorder(), hintText: '@atSign'), onChanged: (text) {}, ), const SizedBox( @@ -64,8 +62,7 @@ class _SecondScreenState extends State { ), TextField( controller: messageController, - decoration: const InputDecoration( - border: OutlineInputBorder(), hintText: 'Enter Message'), + decoration: const InputDecoration(border: OutlineInputBorder(), hintText: 'Enter Message'), onChanged: (text) {}, ), const SizedBox( @@ -82,9 +79,7 @@ class _SecondScreenState extends State { onPressed: () async { Navigator.push( context, - MaterialPageRoute( - builder: (context) => - NotifyScreen(notifyService: NotifyService())), + MaterialPageRoute(builder: (context) => NotifyScreen(notifyService: NotifyService())), ); }, child: const Text( @@ -111,19 +106,19 @@ class _SecondScreenState extends State { return; } - var _isValidAtsign = await checkAtsign(); - if (!_isValidAtsign) { + var isValidAtsign = await checkAtsign(); + if (!isValidAtsign) { showSnackBar('Atsign not valid'); return; } - - var _res = await notifyText( + if (!mounted) return showSnackBar('Something went wrong'); + var res = await notifyText( context, activeAtSign, atSignController.text, messageController.text, ); - if (_res) { + if (res) { messageController.clear(); showSnackBar('Message sent succesfully', color: Colors.green); } else { @@ -135,11 +130,10 @@ class _SecondScreenState extends State { if (atSignController.text.isEmpty) { return false; } else if (!atSignController.text.contains('@')) { - atSignController.text = '@' + atSignController.text; + atSignController.text = '@${atSignController.text}'; } // ignore: deprecated_member_use - var checkPresence = await AtLookupImpl.findSecondary( - atSignController.text, AtEnv.rootDomain, 64); + var checkPresence = await AtLookupImpl.findSecondary(atSignController.text, AtEnv.rootDomain, 64); return checkPresence != null; } diff --git a/packages/at_notify_flutter/example/pubspec.yaml b/packages/at_notify_flutter/example/pubspec.yaml index 6a4161657..9dca82384 100644 --- a/packages/at_notify_flutter/example/pubspec.yaml +++ b/packages/at_notify_flutter/example/pubspec.yaml @@ -28,6 +28,8 @@ environment: # versions available, run `flutter pub outdated`. dependencies: at_app_flutter: ^5.2.0 + at_client_mobile: ^3.2.15 + at_lookup: ^3.0.47 at_notify_flutter: path: ../ at_onboarding_flutter: ^6.1.7 @@ -37,6 +39,7 @@ dependencies: cupertino_icons: ^1.0.6 flutter: sdk: flutter + path_provider: ^2.1.3 dev_dependencies: # The "flutter_lints" package below contains a set of recommended lints to diff --git a/packages/at_onboarding_flutter/lib/screen/at_onboarding_reset_screen.dart b/packages/at_onboarding_flutter/lib/screen/at_onboarding_reset_screen.dart index 9a70f0685..94a9dbd16 100644 --- a/packages/at_onboarding_flutter/lib/screen/at_onboarding_reset_screen.dart +++ b/packages/at_onboarding_flutter/lib/screen/at_onboarding_reset_screen.dart @@ -1,3 +1,4 @@ +import 'package:at_onboarding_flutter/at_onboarding_result.dart'; import 'package:at_onboarding_flutter/localizations/generated/l10n.dart'; import 'package:at_onboarding_flutter/services/at_onboarding_config.dart'; import 'package:at_onboarding_flutter/services/sdk_service.dart'; @@ -6,7 +7,6 @@ import 'package:at_onboarding_flutter/utils/at_onboarding_error_util.dart'; import 'package:at_onboarding_flutter/widgets/at_onboarding_button.dart'; import 'package:at_onboarding_flutter/widgets/at_onboarding_dialog.dart'; import 'package:flutter/material.dart'; -import 'package:at_onboarding_flutter/at_onboarding_result.dart'; /// The screen is used for resetting the paired atSign class AtOnboardingResetScreen extends StatefulWidget { @@ -19,8 +19,7 @@ class AtOnboardingResetScreen extends StatefulWidget { }) : super(key: key); @override - State createState() => - _AtOnboardingResetScreenState(); + State createState() => _AtOnboardingResetScreenState(); } class _AtOnboardingResetScreenState extends State { @@ -84,9 +83,7 @@ class _AtOnboardingResetScreenState extends State { ), ), Expanded( - child: atsignsList.isEmpty - ? _buildEmptyWidget() - : _buildAtSignsWidget(theme), + child: atsignsList.isEmpty ? _buildEmptyWidget() : _buildAtSignsWidget(theme), ), ], ), @@ -116,8 +113,7 @@ class _AtOnboardingResetScreenState extends State { onChanged: (bool? value) { isSelectAll = value!; if (atsignMap.isNotEmpty) { - atsignMap - .updateAll((String? key, bool? value1) => value1 = value); + atsignMap.updateAll((String? key, bool? value1) => value1 = value); } setState(() {}); }, @@ -180,8 +176,7 @@ class _AtOnboardingResetScreenState extends State { padding: EdgeInsets.only( left: AtOnboardingDimens.paddingNormal, right: AtOnboardingDimens.paddingNormal, - bottom: AtOnboardingDimens.paddingNormal + - MediaQuery.of(context).padding.bottom, + bottom: AtOnboardingDimens.paddingNormal + MediaQuery.of(context).padding.bottom, ), constraints: const BoxConstraints( maxWidth: 400, @@ -215,16 +210,16 @@ class _AtOnboardingResetScreenState extends State { Future _resetDevice(List checkedAtsigns) async { await SDKService().resetAtsigns(checkedAtsigns).then((void value) async { - Navigator.pop(context, AtOnboardingResetResult.success); + if (mounted) { + Navigator.pop(context, AtOnboardingResetResult.success); + } }).catchError((Object error) { showErrorDialog(error); }); } Future showErrorDialog(dynamic errorMessage, {String? title}) async { - String? messageString = - AtOnboardingErrorToString().getErrorMessage(errorMessage); - return AtOnboardingDialog.showError( - context: context, message: messageString); + String? messageString = AtOnboardingErrorToString().getErrorMessage(errorMessage); + return AtOnboardingDialog.showError(context: context, message: messageString); } } diff --git a/packages/at_sync_ui_flutter/example/lib/main.dart b/packages/at_sync_ui_flutter/example/lib/main.dart index e855bb3b4..14188f194 100644 --- a/packages/at_sync_ui_flutter/example/lib/main.dart +++ b/packages/at_sync_ui_flutter/example/lib/main.dart @@ -1,11 +1,12 @@ import 'dart:async'; -import 'package:flutter/material.dart'; + +import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart' show AtOnboarding, AtOnboardingConfig, AtOnboardingResultStatus; -import 'package:path_provider/path_provider.dart' - show getApplicationSupportDirectory; -import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart' show getApplicationSupportDirectory; + import 'second_screen.dart'; Future main() async { @@ -23,14 +24,13 @@ Future loadAtClientPreference() async { ..isLocalStoreRequired = true; } -final StreamController updateThemeMode = - StreamController.broadcast(); +final StreamController updateThemeMode = StreamController.broadcast(); class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { @@ -73,9 +73,7 @@ class _MyAppState extends State { actions: [ IconButton( onPressed: () { - updateThemeMode.sink.add(themeMode == ThemeMode.light - ? ThemeMode.dark - : ThemeMode.light); + updateThemeMode.sink.add(themeMode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light); }, icon: Icon( Theme.of(context).brightness == Brightness.light @@ -96,33 +94,32 @@ class _MyAppState extends State { setState(() { atClientPreference = preference; }); - final result = await AtOnboarding.onboard( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); - switch (result.status) { - case AtOnboardingResultStatus.success: - await Navigator.push( - context, - MaterialPageRoute( - builder: (_) => SecondScreen( - activeAtSign: result.atsign!))); - break; - case AtOnboardingResultStatus.error: - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - backgroundColor: Colors.red, - content: Text('An error has occurred'), - ), - ); - break; - case AtOnboardingResultStatus.cancel: - break; + if (context.mounted) { + final result = await AtOnboarding.onboard( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + switch (result.status) { + case AtOnboardingResultStatus.success: + await Navigator.push(context, + MaterialPageRoute(builder: (_) => SecondScreen(activeAtSign: result.atsign!))); + break; + case AtOnboardingResultStatus.error: + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: Colors.red, + content: Text('An error has occurred'), + ), + ); + break; + case AtOnboardingResultStatus.cancel: + break; + } } }, child: const Text('Onboard an atSign'), @@ -132,15 +129,17 @@ class _MyAppState extends State { onPressed: () async { var preference = await futurePreference; atClientPreference = preference; - await AtOnboarding.reset( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); + if (context.mounted) { + await AtOnboarding.reset( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + } }, child: const Text('Reset'), ), diff --git a/packages/at_sync_ui_flutter/example/lib/second_screen.dart b/packages/at_sync_ui_flutter/example/lib/second_screen.dart index bb38e3c56..0fabc252c 100644 --- a/packages/at_sync_ui_flutter/example/lib/second_screen.dart +++ b/packages/at_sync_ui_flutter/example/lib/second_screen.dart @@ -3,6 +3,7 @@ import 'package:at_sync_ui_flutter/at_sync_ui_flutter.dart'; import 'package:at_sync_ui_flutter_example/custom_sync_widget.dart'; import 'package:at_sync_ui_flutter_example/ui_options.dart'; import 'package:flutter/material.dart'; + import 'main.dart'; class SecondScreen extends StatefulWidget { @@ -11,7 +12,7 @@ class SecondScreen extends StatefulWidget { const SecondScreen({required this.activeAtSign, Key? key}) : super(key: key); @override - _SecondScreenState createState() => _SecondScreenState(); + State createState() => _SecondScreenState(); } class _SecondScreenState extends State { @@ -105,8 +106,7 @@ class _SecondScreenState extends State { ), ElevatedButton( onPressed: () async { - await Navigator.push(context, - MaterialPageRoute(builder: (context) => const UIOptions())); + await Navigator.push(context, MaterialPageRoute(builder: (context) => const UIOptions())); }, child: const Text('See all UI options'), ), @@ -125,8 +125,7 @@ class _SecondScreenState extends State { width: 50, fit: BoxFit.cover, gaplessPlayback: true, - image: NetworkImage( - 'https://source.unsplash.com/random'), + image: NetworkImage('https://source.unsplash.com/random'), ), ), )), @@ -167,16 +166,11 @@ class _SecondScreenState extends State { } void showSnackBar(String msg, {bool isError = false}) { - ScaffoldMessenger.of(NavService.navKey.currentContext!) - .showSnackBar(SnackBar( + ScaffoldMessenger.of(NavService.navKey.currentContext!).showSnackBar(SnackBar( backgroundColor: isError ? const Color(0xFFe34040) : Colors.green, content: Text( msg, - style: const TextStyle( - color: Colors.white, - fontSize: 16, - letterSpacing: 0.1, - fontWeight: FontWeight.normal), + style: const TextStyle(color: Colors.white, fontSize: 16, letterSpacing: 0.1, fontWeight: FontWeight.normal), ), )); } diff --git a/packages/at_sync_ui_flutter/example/lib/ui_options.dart b/packages/at_sync_ui_flutter/example/lib/ui_options.dart index 1939c8d7e..f1f6ccdfc 100644 --- a/packages/at_sync_ui_flutter/example/lib/ui_options.dart +++ b/packages/at_sync_ui_flutter/example/lib/ui_options.dart @@ -1,11 +1,11 @@ import 'dart:developer'; -import 'package:at_sync_ui_flutter/at_sync_material.dart' as material; import 'package:at_sync_ui_flutter/at_sync_cupertino.dart' as cupertino; +import 'package:at_sync_ui_flutter/at_sync_material.dart' as material; +import 'package:at_sync_ui_flutter/at_sync_ui.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_colorpicker/flutter_colorpicker.dart'; -import 'package:at_sync_ui_flutter/at_sync_ui.dart'; const double _kNormalPadding = 16; const double _kSmallPadding = 8; @@ -44,8 +44,7 @@ class MyHomePage extends StatefulWidget { State createState() => _MyHomePageState(); } -class _MyHomePageState extends State - with SingleTickerProviderStateMixin { +class _MyHomePageState extends State with SingleTickerProviderStateMixin { bool isLoading = false; double progress = 0.0; @@ -58,8 +57,7 @@ class _MyHomePageState extends State void initState() { super.initState(); - controller = - AnimationController(duration: const Duration(seconds: 5), vsync: this); + controller = AnimationController(duration: const Duration(seconds: 5), vsync: this); animation = Tween(begin: 0.0, end: 1.0).animate(controller) ..addListener(() { setState(() { @@ -107,10 +105,8 @@ class _MyHomePageState extends State const Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Text('Material', - style: TextStyle(fontWeight: FontWeight.bold)), - Text('Cupertino', - style: TextStyle(fontWeight: FontWeight.bold)), + Text('Material', style: TextStyle(fontWeight: FontWeight.bold)), + Text('Cupertino', style: TextStyle(fontWeight: FontWeight.bold)), ], ), const SizedBox(height: _kNormalPadding), @@ -151,18 +147,18 @@ class _MyHomePageState extends State isLoading: isLoading, syncIndicatorColor: _indicatorColor, child: ElevatedButton( - child: const Text('Material'), onPressed: _startLoading, + child: const Text('Material'), ), ), cupertino.AtSyncButton( isLoading: isLoading, syncIndicatorColor: _indicatorColor, child: CupertinoButton( - child: const Text('Cupertino'), color: Colors.grey, padding: const EdgeInsets.symmetric(horizontal: 8), onPressed: _startLoading, + child: const Text('Cupertino'), ), ), ], @@ -234,16 +230,16 @@ class _MyHomePageState extends State flex: 1, child: material.AtSyncText( value: progress, - child: const Text('completed'), indicatorColor: _indicatorColor, + child: const Text('completed'), ), ), Expanded( flex: 1, child: cupertino.AtSyncText( value: progress, - child: const Text('completed'), indicatorColor: _indicatorColor, + child: const Text('completed'), ), ), ], @@ -252,12 +248,12 @@ class _MyHomePageState extends State mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ TextButton( - child: const Text('Material Dialog'), onPressed: _startMaterialDialog, + child: const Text('Material Dialog'), ), TextButton( - child: const Text('Cupertino Dialog'), onPressed: _startCupertinoDialog, + child: const Text('Cupertino Dialog'), ), ], ), @@ -265,12 +261,12 @@ class _MyHomePageState extends State mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ TextButton( - child: const Text('Material SnackBar'), onPressed: _startMaterialSnackBar, + child: const Text('Material SnackBar'), ), TextButton( - child: const Text('Cupertino SnackBar'), onPressed: _startCupertinoSnackBar, + child: const Text('Cupertino SnackBar'), ), ], ), @@ -278,12 +274,12 @@ class _MyHomePageState extends State mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ TextButton( - child: const Text('Loading Dialog'), onPressed: _showLoadingDialog, + child: const Text('Loading Dialog'), ), TextButton( - child: const Text('Loading SnackBar '), onPressed: _showLoadingSnackBar, + child: const Text('Loading SnackBar '), ), ], ), @@ -291,8 +287,8 @@ class _MyHomePageState extends State mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ TextButton( - child: const Text('Show queue loading Dialog'), onPressed: _showQueueLoadingDialog, + child: const Text('Show queue loading Dialog'), ), ], ), diff --git a/packages/at_sync_ui_flutter/example/pubspec.yaml b/packages/at_sync_ui_flutter/example/pubspec.yaml index d24efe612..128754dad 100644 --- a/packages/at_sync_ui_flutter/example/pubspec.yaml +++ b/packages/at_sync_ui_flutter/example/pubspec.yaml @@ -29,13 +29,16 @@ environment: dependencies: at_app_flutter: ^5.2.0 at_backupkey_flutter: ^4.0.10 + at_client_mobile: ^3.2.15 at_onboarding_flutter: ^6.1.7 + at_sync_ui_flutter: ^1.0.11 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.6 flutter: sdk: flutter flutter_colorpicker: ^1.1.0 + path_provider: ^2.1.3 dependency_overrides: at_sync_ui_flutter: diff --git a/packages/at_sync_ui_flutter/lib/at_sync_material.dart b/packages/at_sync_ui_flutter/lib/at_sync_material.dart index d6e7d2356..796d22e33 100644 --- a/packages/at_sync_ui_flutter/lib/at_sync_material.dart +++ b/packages/at_sync_ui_flutter/lib/at_sync_material.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'at_sync_cupertino.dart' as cupertino; +import 'at_sync_cupertino.dart' as cupertino; import 'at_sync_progress_indicator.dart'; const double _kDefaultIndicatorRadius = 10.0; @@ -56,8 +56,7 @@ class AtSyncIndicator extends StatelessWidget { padding: EdgeInsets.all(radius / _kDefaultIndicatorRadius), child: CircularProgressIndicator( value: value, - backgroundColor: backgroundColor ?? - (color ?? _kDefaultActiveTickColor).withAlpha(46), + backgroundColor: backgroundColor ?? (color ?? _kDefaultActiveTickColor).withAlpha(46), color: (color ?? _kDefaultActiveTickColor).withAlpha(146), strokeWidth: radius / _kDefaultIndicatorRadius * 2, ), @@ -133,8 +132,7 @@ class AtSyncLinearProgressIndicator extends AtSyncProgressIndicator { @override Widget build(BuildContext context) { return LinearProgressIndicator( - backgroundColor: - backgroundColor ?? (color ?? _kDefaultActiveTickColor).withAlpha(47), + backgroundColor: backgroundColor ?? (color ?? _kDefaultActiveTickColor).withAlpha(47), color: color ?? _kDefaultActiveTickColor, value: value, minHeight: minHeight ?? 4, @@ -301,6 +299,7 @@ class AtSyncDialog { }, ), ), + // ignore: deprecated_member_use onPopInvoked: (didPop) => Future.value( barrierDismissible, ), @@ -390,7 +389,6 @@ class AtSyncSnackBar { ///[dismiss] Dismiss the snack bar. void dismiss() { - ScaffoldMessenger.of(_context) - .hideCurrentSnackBar(reason: SnackBarClosedReason.dismiss); + ScaffoldMessenger.of(_context).hideCurrentSnackBar(reason: SnackBarClosedReason.dismiss); } } diff --git a/packages/at_theme_flutter/example/lib/main.dart b/packages/at_theme_flutter/example/lib/main.dart index 619fe3647..6269f5609 100644 --- a/packages/at_theme_flutter/example/lib/main.dart +++ b/packages/at_theme_flutter/example/lib/main.dart @@ -1,16 +1,16 @@ import 'dart:async'; + +import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; +import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_onboarding_flutter/at_onboarding_flutter.dart' show AtOnboarding, AtOnboardingConfig, AtOnboardingResultStatus; import 'package:at_theme_flutter/at_theme_flutter.dart'; -import 'package:path_provider/path_provider.dart' - show getApplicationSupportDirectory; -import 'package:at_app_flutter/at_app_flutter.dart' show AtEnv; import 'package:flutter/material.dart'; -import 'package:at_client_mobile/at_client_mobile.dart'; +import 'package:path_provider/path_provider.dart' show getApplicationSupportDirectory; + import 'src/pages/profile_page.dart'; -final StreamController appThemeController = - StreamController.broadcast(); +final StreamController appThemeController = StreamController.broadcast(); Future main() async { await AtEnv.load(); @@ -30,7 +30,7 @@ Future loadAtClientPreference() async { class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State { @@ -66,33 +66,32 @@ class _MyAppState extends State { atClientPreference = preference; }); - final result = await AtOnboarding.onboard( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); - switch (result.status) { - case AtOnboardingResultStatus.success: - await Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) => - const ProfilePage())); - break; - case AtOnboardingResultStatus.error: - ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - backgroundColor: Colors.red, - content: Text('An error has occurred'), - ), - ); - break; - case AtOnboardingResultStatus.cancel: - break; + if (context.mounted) { + final result = await AtOnboarding.onboard( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + switch (result.status) { + case AtOnboardingResultStatus.success: + await Navigator.pushReplacement( + context, MaterialPageRoute(builder: (context) => const ProfilePage())); + break; + case AtOnboardingResultStatus.error: + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + backgroundColor: Colors.red, + content: Text('An error has occurred'), + ), + ); + break; + case AtOnboardingResultStatus.cancel: + break; + } } }, child: const Text('Onboard an atSign'), @@ -105,15 +104,17 @@ class _MyAppState extends State { onPressed: () async { var preference = await futurePreference; atClientPreference = preference; - AtOnboarding.reset( - context: context, - config: AtOnboardingConfig( - atClientPreference: atClientPreference!, - domain: AtEnv.rootDomain, - rootEnvironment: AtEnv.rootEnvironment, - appAPIKey: AtEnv.appApiKey, - ), - ); + if (context.mounted) { + AtOnboarding.reset( + context: context, + config: AtOnboardingConfig( + atClientPreference: atClientPreference!, + domain: AtEnv.rootDomain, + rootEnvironment: AtEnv.rootEnvironment, + appAPIKey: AtEnv.appApiKey, + ), + ); + } }, child: const Text('Reset'), ), diff --git a/packages/at_theme_flutter/example/lib/src/pages/profile_page.dart b/packages/at_theme_flutter/example/lib/src/pages/profile_page.dart index 538c1fd02..4d41e8a9d 100644 --- a/packages/at_theme_flutter/example/lib/src/pages/profile_page.dart +++ b/packages/at_theme_flutter/example/lib/src/pages/profile_page.dart @@ -1,11 +1,11 @@ import 'package:at_app_flutter/at_app_flutter.dart'; +import 'package:at_client_mobile/at_client_mobile.dart'; import 'package:at_common_flutter/services/size_config.dart'; import 'package:at_theme_flutter/at_theme_flutter.dart'; import 'package:at_theme_flutter_example/main.dart'; import 'package:at_theme_flutter_example/src/utils/color_constants.dart'; import 'package:at_theme_flutter_example/src/utils/text_styles.dart'; import 'package:flutter/material.dart'; -import 'package:at_client_mobile/at_client_mobile.dart'; class ProfilePage extends StatefulWidget { final String title; @@ -16,11 +16,10 @@ class ProfilePage extends StatefulWidget { }) : super(key: key); @override - _ProfilePageState createState() => _ProfilePageState(); + State createState() => _ProfilePageState(); } -class _ProfilePageState extends State - with SingleTickerProviderStateMixin { +class _ProfilePageState extends State with SingleTickerProviderStateMixin { late TabController tabController; String? activeAtSign; @@ -82,9 +81,7 @@ class _ProfilePageState extends State ), Text( activeAtSign ?? 'Atsign', - style: TextStyle( - color: appTheme.secondaryColor, - fontSize: 15.toFont), + style: TextStyle(color: appTheme.secondaryColor, fontSize: 15.toFont), ), ], ), @@ -198,8 +195,7 @@ class _ProfilePageState extends State mainAxisSize: MainAxisSize.min, children: [ ListTile( - title: - Text("Default theme setting", style: TextStyles.text15), + title: Text("Default theme setting", style: TextStyles.text15), trailing: Icon(Icons.chevron_right, size: 15.toFont), onTap: () { Navigator.of(context).pop(); @@ -217,13 +213,12 @@ class _ProfilePageState extends State /// we can save theme data without using package ui by using setAppTheme function. ListTile( - title: Text("Set theme without using package UI", - style: TextStyles.text15), + title: Text("Set theme without using package UI", style: TextStyles.text15), trailing: Icon(Icons.chevron_right, size: 15.toFont), onTap: () async { var appTheme = AppTheme.from(); var res = await setAppTheme(appTheme); - if (res) { + if (res && context.mounted) { Navigator.of(context).pop(); appThemeController.sink.add(appTheme); } diff --git a/packages/at_theme_flutter/example/pubspec.yaml b/packages/at_theme_flutter/example/pubspec.yaml index 5d038494e..e3b9a36a6 100644 --- a/packages/at_theme_flutter/example/pubspec.yaml +++ b/packages/at_theme_flutter/example/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. + at_client_mobile: ^3.2.15 at_common_flutter: ^2.0.12 at_onboarding_flutter: ^6.1.7 at_theme_flutter: @@ -38,6 +39,7 @@ dependencies: cupertino_icons: ^1.0.6 flutter: sdk: flutter + path_provider: ^2.1.3 dependency_overrides: at_backupkey_flutter: