From b06a7046f6cffa3a1e49df2900fbb522a2eb8fdd Mon Sep 17 00:00:00 2001 From: Alfreedom <00tango.bromine@icloud.com> Date: Mon, 22 Jul 2024 15:13:21 +0200 Subject: [PATCH] added version --- example/dapp/lib/pages/connect_page.dart | 27 ++++++++++--- example/dapp/pubspec.yaml | 1 + example/wallet/lib/pages/settings_page.dart | 43 ++++++++------------- example/wallet/pubspec.yaml | 2 +- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/example/dapp/lib/pages/connect_page.dart b/example/dapp/lib/pages/connect_page.dart index a6516c7e..7c67759f 100644 --- a/example/dapp/lib/pages/connect_page.dart +++ b/example/dapp/lib/pages/connect_page.dart @@ -5,6 +5,7 @@ import 'package:fl_toast/fl_toast.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart'; @@ -220,10 +221,26 @@ class ConnectPageState extends State { ), child: ListView( children: [ - const Text( - StringConstants.appTitle, - style: StyleConstants.subtitleText, - textAlign: TextAlign.center, + Column( + children: [ + const Text( + 'Flutter Dapp', + style: StyleConstants.subtitleText, + textAlign: TextAlign.center, + ), + FutureBuilder( + future: PackageInfo.fromPlatform(), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return const SizedBox.shrink(); + } + final v = snapshot.data!.version; + final b = snapshot.data!.buildNumber; + const f = String.fromEnvironment('FLUTTER_APP_FLAVOR'); + return Text('$v-$f ($b) - SDK v$packageVersion'); + }, + ), + ], ), const SizedBox( height: StyleConstants.linear16, @@ -234,7 +251,7 @@ class ConnectPageState extends State { textAlign: TextAlign.center, ), const SizedBox( - height: StyleConstants.linear16, + height: StyleConstants.linear8, ), SizedBox( height: StyleConstants.linear48, diff --git a/example/dapp/pubspec.yaml b/example/dapp/pubspec.yaml index 348d48bd..eae8d8d7 100644 --- a/example/dapp/pubspec.yaml +++ b/example/dapp/pubspec.yaml @@ -18,6 +18,7 @@ dependencies: fl_toast: ^3.1.0 url_launcher: ^6.2.2 intl: ^0.19.0 + package_info_plus: ^7.0.0 walletconnect_flutter_v2: path: ../.. diff --git a/example/wallet/lib/pages/settings_page.dart b/example/wallet/lib/pages/settings_page.dart index 64e0e6eb..f6968ede 100644 --- a/example/wallet/lib/pages/settings_page.dart +++ b/example/wallet/lib/pages/settings_page.dart @@ -4,6 +4,7 @@ import 'package:fl_toast/fl_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get_it/get_it.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart'; import 'package:walletconnect_flutter_v2_wallet/dependencies/bottom_sheet/i_bottom_sheet_service.dart'; import 'package:walletconnect_flutter_v2_wallet/dependencies/i_web3wallet_service.dart'; @@ -22,21 +23,6 @@ class SettingsPage extends StatefulWidget { } class _SettingsPageState extends State { - String? version; - @override - void initState() { - super.initState(); - // TODO - // PackageInfo.fromPlatform().then((info) { - // setState(() { - // version = - // '${info.version} (${info.buildNumber}) - SDK v$packageVersion'; - // }); - // }); - - version = const String.fromEnvironment('FLUTTER_APP_FLAVOR'); - } - @override Widget build(BuildContext context) { final keysService = GetIt.I(); @@ -111,6 +97,22 @@ class _SettingsPageState extends State { ); }, ), + const SizedBox(height: 12.0), + FutureBuilder( + future: PackageInfo.fromPlatform(), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return const SizedBox.shrink(); + } + final v = snapshot.data!.version; + final b = snapshot.data!.buildNumber; + const f = String.fromEnvironment('FLUTTER_APP_FLAVOR'); + return _DataContainer( + title: 'App version', + data: '$v-$f ($b) - SDK v$packageVersion', + ); + }, + ), const SizedBox(height: 20.0), const Divider(height: 1.0), const SizedBox(height: 20.0), @@ -161,17 +163,6 @@ class _SettingsPageState extends State { ], ), const SizedBox(height: 12.0), - Row( - children: [ - Expanded( - child: Text( - version ?? '', - textAlign: TextAlign.center, - style: const TextStyle(fontSize: 11.0), - ), - ) - ], - ), ], ), ), diff --git a/example/wallet/pubspec.yaml b/example/wallet/pubspec.yaml index 938173b0..b8fa856a 100644 --- a/example/wallet/pubspec.yaml +++ b/example/wallet/pubspec.yaml @@ -20,7 +20,7 @@ dependencies: get_it: ^7.2.0 eth_sig_util: ^0.0.9 get_it_mixin: ^4.0.0 - # package_info_plus: ^7.0.0 + package_info_plus: ^7.0.0 convert: ^3.0.1 url_launcher: ^6.2.2 kadena_dart_sdk: ^2.3.2