From d035732697ac42993ce458d2c3dc8ad474e6eb6c Mon Sep 17 00:00:00 2001 From: Philipp Hoenisch Date: Tue, 22 Aug 2023 19:59:34 +0200 Subject: [PATCH 1/2] fix: remove feedback plugin I can confirm, the feedback plugin breaks the account drop down. Since it also broke other places in the code, e.g. the confirm dialog after trade which required an extra fix. By removing the feedback plugin we don't need those fixes neither. All of this was undone in this commit. reverts 13d1a48b1c03d9c699464526088e8b2f692b84d1 --- mobile/lib/common/feedback.dart | 69 ---------------- mobile/lib/common/global_keys.dart | 4 - .../lib/common/modal_bottom_sheet_info.dart | 2 +- mobile/lib/common/settings_screen.dart | 14 ---- .../features/trade/trade_bottom_sheet.dart | 2 +- .../trade_bottom_sheet_confirmation.dart | 2 +- mobile/lib/features/trade/trade_screen.dart | 2 +- mobile/lib/features/wallet/wallet_screen.dart | 5 +- mobile/lib/main.dart | 61 +++++++------- .../Flutter/GeneratedPluginRegistrant.swift | 4 - mobile/pubspec.lock | 79 +------------------ mobile/pubspec.yaml | 5 +- 12 files changed, 37 insertions(+), 212 deletions(-) delete mode 100644 mobile/lib/common/feedback.dart delete mode 100644 mobile/lib/common/global_keys.dart diff --git a/mobile/lib/common/feedback.dart b/mobile/lib/common/feedback.dart deleted file mode 100644 index 1c422b57e..000000000 --- a/mobile/lib/common/feedback.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:device_info_plus/device_info_plus.dart'; -import 'package:f_logs/model/flog/flog.dart'; -import 'package:feedback/feedback.dart'; -import 'package:flutter_email_sender/flutter_email_sender.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:url_launcher/url_launcher.dart'; - -Future submitFeedback(UserFeedback feedback) async { - final screenshotFilePath = await writeImageToStorage(feedback.screenshot); - final logs = await FLog.exportLogs(); - - final deviceInfoPlugin = DeviceInfoPlugin(); - String info = ""; - if (Platform.isAndroid) { - final deviceInfo = await deviceInfoPlugin.androidInfo; - info = - "${deviceInfo.model}, Android ${deviceInfo.version.sdkInt}, Release: ${deviceInfo.version.release}"; - } else { - final deviceInfo = await deviceInfoPlugin.iosInfo; - info = "${deviceInfo.name}, ${deviceInfo.systemName} ${deviceInfo.systemVersion}"; - } - - const feedbackEmail = "contact@10101.finance"; - const subject = "10101 Feedback"; - final body = '${feedback.text}\n\n----------\n$info'; - - final Email email = Email( - body: body, - subject: subject, - recipients: [feedbackEmail], - attachmentPaths: [screenshotFilePath, logs.path], - isHTML: false, - ); - try { - await FlutterEmailSender.send(email); - } on Exception catch (e) { - // fallback to using mailto link - // We cannot auto-attach images with this, but the user will still be able to provide text feedback - // We add a message that adds the exception to the body text. - final Uri emailLaunchUri = Uri( - scheme: 'mailto', - path: feedbackEmail, - queryParameters: { - 'subject': subject, - 'body': "$body \n\n----------\n" - "Could not auto-attach images. Had to fallback to mailto link because: $e" - }, - ); - - if (await canLaunchUrl(emailLaunchUri)) { - await launchUrl(emailLaunchUri); - } else { - // If we are unable to use mailto we throw the original exception because it likely contains more useful information. - // If canLaunchUrl returns false this means there is likely no mail application configured, or we are unable to read the intent - rethrow; - } - } -} - -Future writeImageToStorage(Uint8List feedbackScreenshot) async { - final Directory output = await getTemporaryDirectory(); - final String screenshotFilePath = '${output.path}/feedback.png'; - final File screenshotFile = File(screenshotFilePath); - await screenshotFile.writeAsBytes(feedbackScreenshot); - return screenshotFilePath; -} diff --git a/mobile/lib/common/global_keys.dart b/mobile/lib/common/global_keys.dart deleted file mode 100644 index 4dc8f247e..000000000 --- a/mobile/lib/common/global_keys.dart +++ /dev/null @@ -1,4 +0,0 @@ -import 'package:flutter/material.dart'; - -final GlobalKey rootNavigatorKey = GlobalKey(debugLabel: 'root'); -final GlobalKey shellNavigatorKey = GlobalKey(debugLabel: 'shell'); diff --git a/mobile/lib/common/modal_bottom_sheet_info.dart b/mobile/lib/common/modal_bottom_sheet_info.dart index 803da59d9..9e0fb1177 100644 --- a/mobile/lib/common/modal_bottom_sheet_info.dart +++ b/mobile/lib/common/modal_bottom_sheet_info.dart @@ -25,7 +25,7 @@ class ModalBottomSheetInfo extends StatelessWidget { ), ), clipBehavior: Clip.antiAliasWithSaveLayer, - useRootNavigator: false, + useRootNavigator: true, context: context, builder: (BuildContext context) { return Container( diff --git a/mobile/lib/common/settings_screen.dart b/mobile/lib/common/settings_screen.dart index d1fbd0753..fd429d52a 100644 --- a/mobile/lib/common/settings_screen.dart +++ b/mobile/lib/common/settings_screen.dart @@ -2,9 +2,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:f_logs/f_logs.dart'; -import 'package:feedback/feedback.dart'; import 'package:flutter/material.dart'; -import 'package:get_10101/common/feedback.dart'; import 'package:get_10101/common/scrollable_safe_area.dart'; import 'package:get_10101/bridge_generated/bridge_definitions.dart' as bridge; import 'package:intl/intl.dart'; @@ -173,18 +171,6 @@ class _SettingsScreenState extends State { Share.shareXFiles([logFile], text: 'Logs from $now'); }, child: const Text("Share logs")), - const SizedBox(height: 20), - ElevatedButton( - child: const Text('Provide feedback'), - onPressed: () { - try { - BetterFeedback.of(context).show(submitFeedback); - } on Exception catch (e) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Failed to share feedback via email app because: $e'))); - } - }, - ), ])), ); } diff --git a/mobile/lib/features/trade/trade_bottom_sheet.dart b/mobile/lib/features/trade/trade_bottom_sheet.dart index b6fd0d715..beb1bad3a 100644 --- a/mobile/lib/features/trade/trade_bottom_sheet.dart +++ b/mobile/lib/features/trade/trade_bottom_sheet.dart @@ -14,7 +14,7 @@ tradeBottomSheet({required BuildContext context, required Direction direction}) ), clipBehavior: Clip.antiAlias, isScrollControlled: true, - useRootNavigator: false, + useRootNavigator: true, context: context, builder: (BuildContext context) { return SafeArea( diff --git a/mobile/lib/features/trade/trade_bottom_sheet_confirmation.dart b/mobile/lib/features/trade/trade_bottom_sheet_confirmation.dart index 83489e431..925a4df5b 100644 --- a/mobile/lib/features/trade/trade_bottom_sheet_confirmation.dart +++ b/mobile/lib/features/trade/trade_bottom_sheet_confirmation.dart @@ -34,7 +34,7 @@ tradeBottomSheetConfirmation( ), clipBehavior: Clip.antiAlias, isScrollControlled: true, - useRootNavigator: false, + useRootNavigator: true, context: context, builder: (BuildContext context) { return SafeArea( diff --git a/mobile/lib/features/trade/trade_screen.dart b/mobile/lib/features/trade/trade_screen.dart index ebb31580c..6a2156798 100644 --- a/mobile/lib/features/trade/trade_screen.dart +++ b/mobile/lib/features/trade/trade_screen.dart @@ -62,7 +62,7 @@ class TradeScreen extends StatelessWidget { WidgetsBinding.instance.addPostFrameCallback((_) async { return await showDialog( context: context, - useRootNavigator: false, + useRootNavigator: true, barrierDismissible: false, // Prevent user from leaving builder: (BuildContext context) { return Selector( diff --git a/mobile/lib/features/wallet/wallet_screen.dart b/mobile/lib/features/wallet/wallet_screen.dart index f325879e2..95bfd2801 100644 --- a/mobile/lib/features/wallet/wallet_screen.dart +++ b/mobile/lib/features/wallet/wallet_screen.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_speed_dial/flutter_speed_dial.dart'; import 'package:get_10101/common/amount_text.dart'; -import 'package:get_10101/common/global_keys.dart'; import 'package:get_10101/common/submission_status_dialog.dart'; import 'package:get_10101/common/value_data_row.dart'; import 'package:get_10101/features/wallet/seed_screen.dart'; @@ -49,8 +48,8 @@ class _WalletScreenState extends State { sendPaymentChangeNotifier.pendingPayment!.displayed = true; WidgetsBinding.instance.addPostFrameCallback((_) async { return await showDialog( - context: shellNavigatorKey.currentContext!, // Use the context from the navigatorKey - useRootNavigator: false, + context: context, + useRootNavigator: true, builder: (BuildContext context) { return Selector( selector: (_, provider) => provider.pendingPayment!.state, diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart index cee5c63f5..c78532df1 100644 --- a/mobile/lib/main.dart +++ b/mobile/lib/main.dart @@ -1,11 +1,9 @@ import 'dart:convert'; import 'package:f_logs/f_logs.dart'; -import 'package:feedback/feedback.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:flutter/material.dart'; -import 'package:get_10101/common/global_keys.dart'; import 'package:get_10101/firebase_options.dart'; import 'package:get_10101/common/channel_status_notifier.dart'; import 'dart:io'; @@ -57,8 +55,8 @@ import 'package:get_10101/features/wallet/domain/wallet_info.dart'; import 'package:get_10101/ffi.dart' as rust; import 'package:version/version.dart'; -final GlobalKey _feedbackNavigatorKey = - GlobalKey(debugLabel: 'feedback'); +final GlobalKey _rootNavigatorKey = GlobalKey(debugLabel: 'root'); +final GlobalKey _shellNavigatorKey = GlobalKey(debugLabel: 'shell'); void main() { WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); @@ -115,11 +113,11 @@ class _TenTenOneAppState extends State { GlobalKey(); final GoRouter _router = GoRouter( - navigatorKey: rootNavigatorKey, + navigatorKey: _rootNavigatorKey, initialLocation: WalletScreen.route, routes: [ ShellRoute( - navigatorKey: shellNavigatorKey, + navigatorKey: _shellNavigatorKey, builder: (BuildContext context, GoRouterState state, Widget child) { return ScaffoldWithNavBar( child: child, @@ -135,7 +133,7 @@ class _TenTenOneAppState extends State { GoRoute( path: SendScreen.subRouteName, // Use root navigator so the screen overlays the application shell - parentNavigatorKey: rootNavigatorKey, + parentNavigatorKey: _rootNavigatorKey, builder: (BuildContext context, GoRouterState state) { return const SendScreen(); }, @@ -143,7 +141,7 @@ class _TenTenOneAppState extends State { GoRoute( path: SeedScreen.subRouteName, // Use root navigator so the screen overlays the application shell - parentNavigatorKey: rootNavigatorKey, + parentNavigatorKey: _rootNavigatorKey, builder: (BuildContext context, GoRouterState state) { return const SeedScreen(); }, @@ -151,7 +149,7 @@ class _TenTenOneAppState extends State { GoRoute( path: CreateInvoiceScreen.subRouteName, // Use root navigator so the screen overlays the application shell - parentNavigatorKey: rootNavigatorKey, + parentNavigatorKey: _rootNavigatorKey, builder: (BuildContext context, GoRouterState state) { return const CreateInvoiceScreen(); }, @@ -159,7 +157,7 @@ class _TenTenOneAppState extends State { GoRoute( path: ShareInvoiceScreen.subRouteName, // Use root navigator so the screen overlays the application shell - parentNavigatorKey: rootNavigatorKey, + parentNavigatorKey: _rootNavigatorKey, builder: (BuildContext context, GoRouterState state) { return ShareInvoiceScreen(invoice: state.extra as ShareInvoice); }, @@ -167,7 +165,7 @@ class _TenTenOneAppState extends State { ]), GoRoute( path: ScannerScreen.subRouteName, - parentNavigatorKey: rootNavigatorKey, + parentNavigatorKey: _rootNavigatorKey, builder: (BuildContext context, GoRouterState state) { return const ScannerScreen(); }, @@ -185,7 +183,7 @@ class _TenTenOneAppState extends State { ), GoRoute( path: WelcomeScreen.route, - parentNavigatorKey: rootNavigatorKey, + parentNavigatorKey: _rootNavigatorKey, builder: (BuildContext context, GoRouterState state) { return const WelcomeScreen(); }, @@ -232,7 +230,7 @@ class _TenTenOneAppState extends State { if (coordinatorVersion > clientVersion) { FLog.warning(text: "Client out of date. Current version: ${clientVersion.toString()}"); showDialog( - context: shellNavigatorKey.currentContext!, + context: _shellNavigatorKey.currentContext!, builder: (context) => AlertDialog( title: const Text("Update available"), content: Text("A new version of 10101 is available: " @@ -258,25 +256,24 @@ class _TenTenOneAppState extends State { @override Widget build(BuildContext context) { MaterialColor swatch = tenTenOnePurple; - return BetterFeedback( - key: _feedbackNavigatorKey, - child: MaterialApp.router( - title: "10101", - scaffoldMessengerKey: scaffoldMessengerKey, - theme: ThemeData( - primarySwatch: swatch, - iconTheme: IconThemeData( - color: tenTenOnePurple.shade800, - size: 32, - ), - extensions: >[ - const TradeTheme(), - WalletTheme(colors: ColorScheme.fromSwatch(primarySwatch: swatch)), - ], - ), - routerConfig: _router, - debugShowCheckedModeBanner: false, - )); + + return MaterialApp.router( + title: "10101", + scaffoldMessengerKey: scaffoldMessengerKey, + theme: ThemeData( + primarySwatch: swatch, + iconTheme: IconThemeData( + color: tenTenOnePurple.shade800, + size: 32, + ), + extensions: >[ + const TradeTheme(), + WalletTheme(colors: ColorScheme.fromSwatch(primarySwatch: swatch)), + ], + ), + routerConfig: _router, + debugShowCheckedModeBanner: false, + ); } Future init(bridge.Config config) async { diff --git a/mobile/macos/Flutter/GeneratedPluginRegistrant.swift b/mobile/macos/Flutter/GeneratedPluginRegistrant.swift index 1a0229bd8..005839299 100644 --- a/mobile/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/mobile/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,7 +5,6 @@ import FlutterMacOS import Foundation -import device_info_plus import firebase_core import firebase_messaging import flutter_local_notifications @@ -13,10 +12,8 @@ import package_info_plus import path_provider_foundation import share_plus import shared_preferences_foundation -import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) @@ -24,5 +21,4 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) - UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock index e626638fd..a405f7860 100644 --- a/mobile/pubspec.lock +++ b/mobile/pubspec.lock @@ -273,22 +273,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.2" - device_info_plus: - dependency: "direct main" - description: - name: device_info_plus - sha256: "86add5ef97215562d2e090535b0a16f197902b10c369c558a100e74ea06e8659" - url: "https://pub.dev" - source: hosted - version: "9.0.3" - device_info_plus_platform_interface: - dependency: transitive - description: - name: device_info_plus_platform_interface - sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 - url: "https://pub.dev" - source: hosted - version: "7.0.0" expandable: dependency: "direct main" description: @@ -313,14 +297,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" - feedback: - dependency: "direct main" - description: - name: feedback - sha256: a3a18af1d490b1e172cc354f1270760d14d2d0d5bb65e2d3710565de88507f33 - url: "https://pub.dev" - source: hosted - version: "2.6.0" ffi: dependency: "direct main" description: @@ -406,14 +382,6 @@ packages: description: flutter source: sdk version: "0.0.0" - flutter_email_sender: - dependency: "direct main" - description: - name: flutter_email_sender - sha256: "52b713a67a966be4d9e6f68a323fc0a5bc2da71c567eb451af1aa90d30adbc3a" - url: "https://pub.dev" - source: hosted - version: "6.0.1" flutter_launcher_icons: dependency: "direct dev" description: @@ -454,11 +422,6 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0+1" - flutter_localizations: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" flutter_native_splash: dependency: "direct main" description: @@ -1178,30 +1141,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.2" - url_launcher: - dependency: "direct main" - description: - name: url_launcher - sha256: "781bd58a1eb16069412365c98597726cd8810ae27435f04b3b4d3a470bacd61e" - url: "https://pub.dev" - source: hosted - version: "6.1.12" - url_launcher_android: - dependency: transitive - description: - name: url_launcher_android - sha256: "3dd2388cc0c42912eee04434531a26a82512b9cb1827e0214430c9bcbddfe025" - url: "https://pub.dev" - source: hosted - version: "6.0.38" - url_launcher_ios: - dependency: transitive - description: - name: url_launcher_ios - sha256: "9af7ea73259886b92199f9e42c116072f05ff9bea2dcb339ab935dfc957392c2" - url: "https://pub.dev" - source: hosted - version: "6.1.4" url_launcher_linux: dependency: transitive description: @@ -1210,14 +1149,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.5" - url_launcher_macos: - dependency: transitive - description: - name: url_launcher_macos - sha256: "1c4fdc0bfea61a70792ce97157e5cc17260f61abbe4f39354513f39ec6fd73b1" - url: "https://pub.dev" - source: hosted - version: "3.0.6" url_launcher_platform_interface: dependency: transitive description: @@ -1330,14 +1261,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.5" - win32_registry: - dependency: transitive - description: - name: win32_registry - sha256: e4506d60b7244251bc59df15656a3093501c37fb5af02105a944d73eb95be4c9 - url: "https://pub.dev" - source: hosted - version: "1.1.1" xdg_directories: dependency: transitive description: @@ -1380,4 +1303,4 @@ packages: version: "2.1.1" sdks: dart: ">=3.0.0 <4.0.0" - flutter: ">=3.10.0" + flutter: ">=3.7.0" diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 8dda3475d..cf405d999 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -38,10 +38,7 @@ dependencies: firebase_core: ^2.15.0 firebase_messaging: ^14.6.5 flutter_local_notifications: ^15.1.0+1 - flutter_email_sender: ^6.0.1 - device_info_plus: ^9.0.3 - url_launcher: ^6.1.12 - feedback: ^2.6.0 +# Needed for Flogs (unmaintained package) dependency_overrides: intl: ^0.18.0 dev_dependencies: From 19dda11473ba686aea758d7ef688e761682464c6 Mon Sep 17 00:00:00 2001 From: Philipp Hoenisch Date: Tue, 22 Aug 2023 20:52:55 +0200 Subject: [PATCH 2/2] feat: show free disk space in CI helps with #1138 --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3c21990c..746db184d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,8 +147,13 @@ jobs: run: | docker-compose up -d sleep 10 # We need to give docker a bit of time to startup + - name: show disk space before tests + run: df -h - name: Test containers are up run: | curl -d '{"address":"bcrt1qylgu6ffkp3p0m8tw8kp4tt2dmdh755f4r5dq7s", "amount":"0.1"}' -H "Content-Type: application/json" -X POST http://localhost:3000/faucet - name: Run e2e tests run: just e2e --nocapture + - name: show disk space after tests + if: always() + run: df -h