From a5e6173eef7261c4082242d5560753e685be778a Mon Sep 17 00:00:00 2001 From: IronJam11 Date: Wed, 17 Sep 2025 21:19:58 +0530 Subject: [PATCH 1/5] fix: reconnecting wallet button --- lib/components/universal_navbar.dart | 88 ++++++++++++++++---- lib/providers/wallet_provider.dart | 36 +++++++- lib/widgets/basic_scaffold.dart | 58 +++++++++---- lib/widgets/wallet_not_connected_widget.dart | 11 +-- lib/widgets/wrong_chain_widget.dart | 2 +- 5 files changed, 149 insertions(+), 46 deletions(-) diff --git a/lib/components/universal_navbar.dart b/lib/components/universal_navbar.dart index b73d52f..8704ec6 100644 --- a/lib/components/universal_navbar.dart +++ b/lib/components/universal_navbar.dart @@ -360,15 +360,48 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget { ); } - Widget _buildConnectButton( +Widget _buildConnectButton( BuildContext context, WalletProvider walletProvider) { + // Determine the state and corresponding visual properties + Color backgroundColor; + Color borderColor; + Color textColor; + IconData iconData; + String buttonText; + bool isClickable; + + if (walletProvider.isConnecting) { + backgroundColor = Colors.orange.shade50; + borderColor = Colors.orange; + textColor = Colors.orange.shade700; + iconData = Icons.sync; + buttonText = 'Retry'; + isClickable = true; // Keep clickable for retry functionality + } else if (walletProvider.isConnected) { + // This case shouldn't normally happen as connected state shows the wallet menu + backgroundColor = Colors.green.shade50; + borderColor = Colors.green; + textColor = Colors.green.shade700; + iconData = Icons.account_balance_wallet; + buttonText = 'Connected'; + isClickable = true; + } else { + // Disconnected state + backgroundColor = Colors.white; + borderColor = Colors.green; + textColor = Colors.green.shade700; + iconData = Icons.account_balance_wallet; + buttonText = 'Connect'; + isClickable = true; + } + return Container( constraints: const BoxConstraints(maxWidth: 80), // Limit max width decoration: BoxDecoration( - color: Colors.white, + color: backgroundColor, borderRadius: BorderRadius.circular(16), border: Border.all( - color: Colors.green, + color: borderColor, width: 1, ), boxShadow: [ @@ -384,31 +417,52 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget { child: InkWell( borderRadius: BorderRadius.circular(16), onTap: () async { - final uri = await walletProvider.connectWallet(); - if (uri != null && context.mounted) { - showDialog( - context: context, - builder: (context) => WalletConnectDialog(uri: uri), - ); + if (walletProvider.isConnecting) { + // If connecting, allow force reconnect + final uri = await walletProvider.forceReconnect(); + if (uri != null && context.mounted) { + showDialog( + context: context, + builder: (context) => WalletConnectDialog(uri: uri), + ); + } + } else { + // Normal connect flow + final uri = await walletProvider.connectWallet(); + if (uri != null && context.mounted) { + showDialog( + context: context, + builder: (context) => WalletConnectDialog(uri: uri), + ); + } } - }, + }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0), child: Row( mainAxisSize: MainAxisSize.min, children: [ - Icon( - Icons.account_balance_wallet, - size: 16, - color: Colors.green[700], - ), + walletProvider.isConnecting + ? SizedBox( + width: 16, + height: 16, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation(textColor), + ), + ) + : Icon( + iconData, + size: 16, + color: textColor, + ), const SizedBox(width: 4), Flexible( child: Text( - 'Connect', + buttonText, style: TextStyle( - color: Colors.green[700], + color: textColor, fontWeight: FontWeight.w600, fontSize: 12, ), diff --git a/lib/providers/wallet_provider.dart b/lib/providers/wallet_provider.dart index 7150bb4..9cd3772 100644 --- a/lib/providers/wallet_provider.dart +++ b/lib/providers/wallet_provider.dart @@ -186,12 +186,40 @@ class WalletProvider extends ChangeNotifier { } } + Future forceReconnect() async { + _updateStatus("Forcing reconnection..."); + _isConnected = false; + _isConnecting = false; + _currentAddress = null; + _currentChainId = null; + notifyListeners(); + + try { + await disconnectWallet(); + final uri = await connectWallet(); // Return the URI + return uri; + } catch (e) { + _updateStatus("Force reconnect failed: ${e.toString()}"); + _isConnecting = false; + notifyListeners(); + rethrow; + } + } + Future connectWallet() async { - if (_initializationState != InitializationState.initialized || - _isConnecting) { - return null; + if (_isConnected) { + _updateStatus('Already connected.'); + throw Exception('Wallet is already connected.'); + } + + if (_isConnecting) { + _updateStatus('Connection already in progress.'); + throw Exception('A connection attempt is already in progress.'); } + if (_initializationState != InitializationState.initialized) { + throw Exception('Web3App is not initialized.'); + } _updateStatus('Creating connection...'); _isConnecting = true; notifyListeners(); @@ -679,7 +707,7 @@ class WalletProvider extends ChangeNotifier { Future disconnectWallet() async { if (!_isConnected) return; - + logger.d("Tried to disconnect"); try { final sessions = _web3App!.sessions.getAll(); if (sessions.isNotEmpty) { diff --git a/lib/widgets/basic_scaffold.dart b/lib/widgets/basic_scaffold.dart index df54a34..4eebfa1 100644 --- a/lib/widgets/basic_scaffold.dart +++ b/lib/widgets/basic_scaffold.dart @@ -6,6 +6,8 @@ import 'package:tree_planting_protocol/components/bottom_navigation_widget.dart' import 'package:tree_planting_protocol/providers/wallet_provider.dart'; import 'package:tree_planting_protocol/widgets/wrong_chain_widget.dart' show buildWrongChainWidget; +import 'package:tree_planting_protocol/widgets/wallet_not_connected_widget.dart' + show buildWalletNotConnectedWidget; class BaseScaffold extends StatelessWidget { final Widget body; @@ -28,20 +30,48 @@ class BaseScaffold extends StatelessWidget { @override Widget build(BuildContext context) { final currentRoute = GoRouterState.of(context).uri.toString(); - final provider = Provider.of(context, listen: false); - bool isCorrectChain = provider.isValidCurrentChain; - return Scaffold( - appBar: UniversalNavbar(title: title, actions: actions), - extendBodyBehindAppBar: extendBodyBehindAppBar, - body: isCorrectChain - ? SafeArea( - child: body, - ) - : Container(child: buildWrongChainWidget(context)), - floatingActionButton: floatingActionButton, - bottomNavigationBar: showBottomNavigation - ? BottomNavigationWidget(currentRoute: currentRoute) - : null, + + return Consumer( + builder: (context, provider, child) { + final bool isWalletConnecting = provider.isConnecting; + final bool isWalletConnected = provider.isConnected; + final bool isCorrectChain = provider.isValidCurrentChain; + + Widget bodyContent; + + if (isWalletConnecting) { + bodyContent = Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const CircularProgressIndicator(), + const Text("Connecting"), + ElevatedButton( + onPressed: () async { + await provider.forceReconnect(); + }, + child: const Text("Force Reconnect")) + ], + )); + } else if (!isWalletConnected) { + bodyContent = buildWalletNotConnectedWidget(context); + } else if (!isCorrectChain) { + bodyContent = buildWrongChainWidget(context); + } else { + bodyContent = SafeArea(child: body); + } + + return Scaffold( + appBar: UniversalNavbar(title: title, actions: actions), + extendBodyBehindAppBar: extendBodyBehindAppBar, + body: bodyContent, + floatingActionButton: floatingActionButton, + bottomNavigationBar: showBottomNavigation + ? BottomNavigationWidget(currentRoute: currentRoute) + : null, + ); + }, ); } } diff --git a/lib/widgets/wallet_not_connected_widget.dart b/lib/widgets/wallet_not_connected_widget.dart index ad78ed8..84d3d7f 100644 --- a/lib/widgets/wallet_not_connected_widget.dart +++ b/lib/widgets/wallet_not_connected_widget.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:tree_planting_protocol/providers/wallet_provider.dart'; -import 'package:provider/provider.dart'; Widget buildWalletNotConnectedWidget(BuildContext context) { return Center( @@ -22,14 +20,7 @@ Widget buildWalletNotConnectedWidget(BuildContext context) { ), ), const SizedBox(height: 16), - ElevatedButton( - onPressed: () { - final walletProvider = - Provider.of(context, listen: false); - walletProvider.connectWallet(); - }, - child: const Text('Connect Wallet'), - ), + ], ), ); diff --git a/lib/widgets/wrong_chain_widget.dart b/lib/widgets/wrong_chain_widget.dart index 5f76d85..b34cf3d 100644 --- a/lib/widgets/wrong_chain_widget.dart +++ b/lib/widgets/wrong_chain_widget.dart @@ -24,7 +24,7 @@ Widget buildWrongChainWidget(BuildContext context) { ), const SizedBox(height: 16), Text( - 'Please switch to the chain supported by Tree Planting Protocol i.e. ${walletProvider.correctChainId}', + 'Please switch to the chain supported by Tree Planting Protocol', textAlign: TextAlign.center, style: const TextStyle( fontSize: 16, From 341516d191a288ee6f196d9ddca0481d6da61182 Mon Sep 17 00:00:00 2001 From: IronJam11 Date: Sat, 20 Sep 2025 22:01:27 +0530 Subject: [PATCH 2/5] refactor: add consistent UI colors --- android/app/src/main/AndroidManifest.xml | 14 +- lib/components/universal_navbar.dart | 49 ++++--- lib/pages/mint_nft/mint_nft_coordinates.dart | 92 ++++++------ lib/pages/mint_nft/mint_nft_details.dart | 98 +++++++------ lib/pages/mint_nft/mint_nft_images.dart | 67 +++++---- lib/pages/mint_nft/submit_nft_page.dart | 27 ++-- .../user_organisations_page.dart | 1 + lib/pages/register_user_page.dart | 84 +++++------ lib/pages/tree_details_page.dart | 131 +++++++++--------- lib/providers/wallet_provider.dart | 2 +- lib/utils/constants/ui/color_constants.dart | 56 ++++++++ lib/utils/services/conversion_functions.dart | 5 + lib/widgets/basic_scaffold.dart | 27 ++-- .../map_widgets/flutter_map_widget.dart | 46 +++--- .../static_map_display_widget.dart | 2 +- .../tree_nft_details_verifiers_widget.dart | 95 +++++-------- .../tree_nft_view_details_with_map.dart | 9 +- .../tree_nft_view_widget.dart | 6 +- .../nft_display_utils/user_nfts_widget.dart | 9 +- .../profile_section_widget.dart | 12 +- lib/widgets/wallet_not_connected_widget.dart | 10 +- lib/widgets/wrong_chain_widget.dart | 11 +- 22 files changed, 444 insertions(+), 409 deletions(-) create mode 100644 lib/pages/organisations_pages/user_organisations_page.dart create mode 100644 lib/utils/constants/ui/color_constants.dart create mode 100644 lib/utils/services/conversion_functions.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 9c0f441..6f6c964 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -17,14 +17,15 @@ - - - + + + + + + + + + + + diff --git a/lib/components/universal_navbar.dart b/lib/components/universal_navbar.dart index 8704ec6..9b7d166 100644 --- a/lib/components/universal_navbar.dart +++ b/lib/components/universal_navbar.dart @@ -11,8 +11,9 @@ import 'package:tree_planting_protocol/utils/services/switch_chain_utils.dart'; class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget { final String? title; final List? actions; + final Widget? leading; - const UniversalNavbar({super.key, this.title, this.actions}); + const UniversalNavbar({super.key, this.title, this.actions, this.leading}); @override Size get preferredSize => const Size.fromHeight(120.0); @@ -43,6 +44,9 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget { padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Row( children: [ + if (leading != null) ...[ + leading!, + ], Expanded( flex: 2, child: Row( @@ -59,7 +63,7 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget { ), ), child: Image.asset( - 'assets/tree-navbar-images/logo.png', // Fixed path to match your folder structure + 'assets/tree-navbar-images/logo.png', width: 28, height: 28, fit: BoxFit.contain, @@ -186,7 +190,7 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget { width: plantWidth, height: plantWidth, child: Image.asset( - 'assets/tree-navbar-images/$imagePath', // Fixed: consistent path + 'assets/tree-navbar-images/$imagePath', width: 28, height: 28, fit: BoxFit.contain, @@ -213,7 +217,7 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget { height: plantWidth, margin: EdgeInsets.zero, child: Image.asset( - 'assets/tree-navbar-images/$imagePath', // Fixed: consistent path + 'assets/tree-navbar-images/$imagePath', width: 35, height: 35, fit: BoxFit.contain, @@ -360,7 +364,7 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget { ); } -Widget _buildConnectButton( + Widget _buildConnectButton( BuildContext context, WalletProvider walletProvider) { // Determine the state and corresponding visual properties Color backgroundColor; @@ -368,7 +372,6 @@ Widget _buildConnectButton( Color textColor; IconData iconData; String buttonText; - bool isClickable; if (walletProvider.isConnecting) { backgroundColor = Colors.orange.shade50; @@ -376,7 +379,7 @@ Widget _buildConnectButton( textColor = Colors.orange.shade700; iconData = Icons.sync; buttonText = 'Retry'; - isClickable = true; // Keep clickable for retry functionality +// Keep clickable for retry functionality } else if (walletProvider.isConnected) { // This case shouldn't normally happen as connected state shows the wallet menu backgroundColor = Colors.green.shade50; @@ -384,7 +387,6 @@ Widget _buildConnectButton( textColor = Colors.green.shade700; iconData = Icons.account_balance_wallet; buttonText = 'Connected'; - isClickable = true; } else { // Disconnected state backgroundColor = Colors.white; @@ -392,7 +394,6 @@ Widget _buildConnectButton( textColor = Colors.green.shade700; iconData = Icons.account_balance_wallet; buttonText = 'Connect'; - isClickable = true; } return Container( @@ -418,7 +419,6 @@ Widget _buildConnectButton( borderRadius: BorderRadius.circular(16), onTap: () async { if (walletProvider.isConnecting) { - // If connecting, allow force reconnect final uri = await walletProvider.forceReconnect(); if (uri != null && context.mounted) { showDialog( @@ -427,7 +427,6 @@ Widget _buildConnectButton( ); } } else { - // Normal connect flow final uri = await walletProvider.connectWallet(); if (uri != null && context.mounted) { showDialog( @@ -436,27 +435,27 @@ Widget _buildConnectButton( ); } } - }, + }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0), child: Row( mainAxisSize: MainAxisSize.min, children: [ - walletProvider.isConnecting - ? SizedBox( - width: 16, - height: 16, - child: CircularProgressIndicator( - strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(textColor), + walletProvider.isConnecting + ? SizedBox( + width: 16, + height: 16, + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: AlwaysStoppedAnimation(textColor), + ), + ) + : Icon( + iconData, + size: 16, + color: textColor, ), - ) - : Icon( - iconData, - size: 16, - color: textColor, - ), const SizedBox(width: 4), Flexible( child: Text( diff --git a/lib/pages/mint_nft/mint_nft_coordinates.dart b/lib/pages/mint_nft/mint_nft_coordinates.dart index d7fdcd6..6e2fc1d 100644 --- a/lib/pages/mint_nft/mint_nft_coordinates.dart +++ b/lib/pages/mint_nft/mint_nft_coordinates.dart @@ -1,9 +1,12 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; +import 'package:http/http.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/mint_nft_provider.dart'; import 'package:tree_planting_protocol/utils/constants/route_constants.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; +import 'package:tree_planting_protocol/utils/logger.dart'; import 'package:tree_planting_protocol/widgets/basic_scaffold.dart'; import 'package:tree_planting_protocol/widgets/map_widgets/flutter_map_widget.dart'; import 'package:tree_planting_protocol/widgets/nft_display_utils/tree_nft_view_widget.dart'; @@ -135,7 +138,19 @@ class _MintNftCoordinatesPageState extends State { return; } - final geohash = geoHasher.encode(lat, lng, precision: 12); + String geohash; + try { + logger.d("About to generate geohash for: lat=$lat, lng=$lng"); + geohash = geoHasher.encode(lat, lng, precision: 12); + logger.d("Generated geohash: $geohash"); + } catch (geohashError) { + logger.d("Geohash error: $geohashError"); + _showCustomSnackBar( + "Error generating location code: $geohashError", + isError: true, + ); + return; + } Provider.of(context, listen: false).setLatitude(lat); Provider.of(context, listen: false).setLongitude(lng); @@ -148,7 +163,7 @@ class _MintNftCoordinatesPageState extends State { context.push(RouteConstants.mintNftDetailsPath); } catch (e) { _showCustomSnackBar( - "Please enter valid numeric coordinates.", + "Please enter valid numeric coordinates. $latitude", isError: true, ); } @@ -179,7 +194,7 @@ class _MintNftCoordinatesPageState extends State { children: [ Icon( isError ? Icons.error_outline : Icons.check_circle_outline, - color: Colors.white, + color: getThemeColors(context)['primary'], size: 20, ), const SizedBox(width: 8), @@ -219,7 +234,7 @@ class _MintNftCoordinatesPageState extends State { ), child: Column( children: [ - _buildFormSection(screenWidth, screenHeight), + _buildFormSection(screenWidth, screenHeight, context), const SizedBox(height: 32), ], ), @@ -227,27 +242,13 @@ class _MintNftCoordinatesPageState extends State { ); } - Widget _buildFormSection(double screenWidth, double screenHeight) { + Widget _buildFormSection( + double screenWidth, double screenHeight, BuildContext context) { return Container( width: double.infinity, constraints: BoxConstraints(maxWidth: screenWidth * 0.92), decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFF1CD381), - const Color(0xFFFAEB96), - ], - ), borderRadius: BorderRadius.circular(24), - boxShadow: [ - BoxShadow( - color: const Color(0xFF1CD381), - blurRadius: 20, - offset: const Offset(0, 8), - ), - ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -256,12 +257,6 @@ class _MintNftCoordinatesPageState extends State { width: double.infinity, padding: const EdgeInsets.all(24), decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - const Color(0xFF1CD381), - const Color(0xFF1CD381), - ], - ), borderRadius: const BorderRadius.only( topLeft: Radius.circular(24), topRight: Radius.circular(24), @@ -272,17 +267,16 @@ class _MintNftCoordinatesPageState extends State { Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(14), ), - child: const Icon( + child: Icon( Icons.location_on, - color: Colors.white, + color: getThemeColors(context)['primary'], size: 28, ), ), const SizedBox(width: 16), - const Expanded( + Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -291,14 +285,14 @@ class _MintNftCoordinatesPageState extends State { style: TextStyle( fontSize: 22, fontWeight: FontWeight.bold, - color: Colors.white, + color: getThemeColors(context)['primary'], ), ), Text( 'Mark where your tree is planted', style: TextStyle( fontSize: 14, - color: Colors.white70, + color: getThemeColors(context)['textPrimary'], ), ), ], @@ -307,39 +301,36 @@ class _MintNftCoordinatesPageState extends State { ], ), ), - - // Content Padding( padding: const EdgeInsets.all(24), child: Column( children: [ - _buildLocationStatus(), const SizedBox(height: 24), _buildMapSection(screenHeight), const SizedBox(height: 24), Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( - color: const Color(0xFFFAEB96), + color: primaryYellowColor, borderRadius: BorderRadius.circular(12), border: Border.all( - color: const Color(0xFFFAEB96), + color: getThemeColors(context)['secondary']!, ), ), child: Row( children: [ Icon( Icons.info_outline, - color: const Color(0xFF1CD381), + color: getThemeColors(context)['primary'], size: 20, ), const SizedBox(width: 12), - const Expanded( + Expanded( child: Text( 'Tap on the map or enter coordinates manually below', style: TextStyle( fontSize: 14, - color: Colors.black87, + color: getThemeColors(context)['textPrimary'], fontWeight: FontWeight.w500, ), ), @@ -376,20 +367,19 @@ class _MintNftCoordinatesPageState extends State { child: ElevatedButton( onPressed: submitCoordinates, style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF1CD381), - foregroundColor: Colors.white, + backgroundColor: getThemeColors(context)['primary'], elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: const Color(0xFF1CD381), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text( + Text( 'Continue', style: TextStyle( + color: getThemeColors(context)['textPrimary'], fontSize: 18, fontWeight: FontWeight.w600, ), @@ -398,7 +388,7 @@ class _MintNftCoordinatesPageState extends State { Container( padding: const EdgeInsets.all(4), decoration: BoxDecoration( - color: Colors.white, + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(6), ), child: const Icon( @@ -428,9 +418,7 @@ class _MintNftCoordinatesPageState extends State { color: Colors.white, borderRadius: BorderRadius.circular(12), border: Border.all( - color: isLoading - ? Colors.orange - : (isManual ? const Color(0xFFFAEB96) : const Color(0xFF1CD381)), + color: isLoading ? primaryYellowColor : primaryGreenColor, width: 2, ), ), @@ -456,7 +444,7 @@ class _MintNftCoordinatesPageState extends State { isManual ? Icons.edit_location : Icons.my_location, size: 20, color: isManual - ? Colors.orange.shade700 + ? const Color(0xFFFAEB96) : const Color(0xFF1CD381), ), ), @@ -495,7 +483,7 @@ class _MintNftCoordinatesPageState extends State { onPressed: _refreshLocation, icon: const Icon(Icons.refresh, size: 20), style: IconButton.styleFrom( - backgroundColor: const Color(0xFF1CD381), + backgroundColor: getThemeColors(context)['background'], foregroundColor: const Color(0xFF1CD381), ), ), @@ -562,7 +550,7 @@ class _MintNftCoordinatesPageState extends State { ), child: Icon( icon, - color: const Color(0xFF1CD381), + color: getThemeColors(context)['textPrimary'], size: 14, ), ), @@ -583,7 +571,7 @@ class _MintNftCoordinatesPageState extends State { color: Colors.white, borderRadius: BorderRadius.circular(12), border: Border.all( - color: const Color(0xFFFAEB96), + color: getThemeColors(context)['secondary']!, width: 2, ), ), diff --git a/lib/pages/mint_nft/mint_nft_details.dart b/lib/pages/mint_nft/mint_nft_details.dart index 17e4778..1be8fd5 100644 --- a/lib/pages/mint_nft/mint_nft_details.dart +++ b/lib/pages/mint_nft/mint_nft_details.dart @@ -3,6 +3,7 @@ import 'package:go_router/go_router.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/mint_nft_provider.dart'; import 'package:tree_planting_protocol/utils/constants/route_constants.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/widgets/basic_scaffold.dart'; import 'package:tree_planting_protocol/widgets/nft_display_utils/tree_nft_view_details_with_map.dart'; @@ -59,8 +60,9 @@ class _MintNftCoordinatesPageState extends State { ), ], ), - backgroundColor: - isError ? Colors.red.shade400 : const Color(0xFF1CD381), + backgroundColor: isError + ? getThemeColors(context)['secondaryButton'] + : getThemeColors(context)['primaryButton'], behavior: SnackBarBehavior.floating, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), @@ -76,6 +78,10 @@ class _MintNftCoordinatesPageState extends State { return BaseScaffold( title: "NFT Details", + leading: IconButton( + icon: const Icon(Icons.arrow_back), + onPressed: () => context.pop(), + ), body: SingleChildScrollView( padding: EdgeInsets.symmetric( horizontal: screenWidth * 0.05, @@ -85,7 +91,7 @@ class _MintNftCoordinatesPageState extends State { children: [ _buildFormSection(screenWidth), const SizedBox(height: 32), - _buildPreviewSection(), + // _buildPreviewSection(), ], ), ), @@ -97,22 +103,14 @@ class _MintNftCoordinatesPageState extends State { width: double.infinity, constraints: BoxConstraints(maxWidth: screenWidth * 0.92), decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFF1CD381), - const Color(0xFFFAEB96), - ], - ), borderRadius: BorderRadius.circular(24), - boxShadow: [ - BoxShadow( - color: const Color(0xFF1CD381), - blurRadius: 20, - offset: const Offset(0, 8), - ), - ], + // boxShadow: [ + // BoxShadow( + // color: const Color(0xFF1CD381), + // blurRadius: 20, + // offset: const Offset(0, 8), + // ), + // ], ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -121,12 +119,12 @@ class _MintNftCoordinatesPageState extends State { width: double.infinity, padding: const EdgeInsets.all(24), decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - const Color(0xFF1CD381), - const Color(0xFF1CD381), - ], - ), + // gradient: LinearGradient( + // colors: [ + // const Color(0xFF1CD381), + // const Color(0xFF1CD381), + // ], + // ), borderRadius: const BorderRadius.only( topLeft: Radius.circular(24), topRight: Radius.circular(24), @@ -137,33 +135,33 @@ class _MintNftCoordinatesPageState extends State { Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( - color: Colors.white, + color: getThemeColors(context)['background'], borderRadius: BorderRadius.circular(14), ), - child: const Icon( + child: Icon( Icons.edit_note, - color: Colors.white, + color: getThemeColors(context)['icon'], size: 28, ), ), const SizedBox(width: 16), - const Expanded( + Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'NFT Details Form', + 'NFT Details', style: TextStyle( fontSize: 22, fontWeight: FontWeight.bold, - color: Colors.white, + color: getThemeColors(context)['textPrimary'], ), ), Text( 'Tell us about your tree', style: TextStyle( fontSize: 14, - color: Colors.white70, + color: getThemeColors(context)['textPrimary'], ), ), ], @@ -200,13 +198,12 @@ class _MintNftCoordinatesPageState extends State { child: ElevatedButton( onPressed: submitDetails, style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF1CD381), - foregroundColor: Colors.white, + backgroundColor: getThemeColors(context)['primary'], elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), - shadowColor: const Color(0xFF1CD381), + shadowColor: primaryGreenColor, ), child: Row( mainAxisAlignment: MainAxisAlignment.center, @@ -222,7 +219,7 @@ class _MintNftCoordinatesPageState extends State { Container( padding: const EdgeInsets.all(4), decoration: BoxDecoration( - color: Colors.white, + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(6), ), child: const Icon( @@ -258,12 +255,11 @@ class _MintNftCoordinatesPageState extends State { Container( padding: const EdgeInsets.all(6), decoration: BoxDecoration( - color: const Color(0xFF1CD381), borderRadius: BorderRadius.circular(8), ), child: Icon( icon, - color: const Color(0xFF1CD381), + color: getThemeColors(context)['icon'], size: 18, ), ), @@ -287,27 +283,27 @@ class _MintNftCoordinatesPageState extends State { color: const Color(0xFFFAEB96), width: 2, ), - boxShadow: [ - BoxShadow( - color: const Color(0xFF1CD381), - blurRadius: 8, - offset: const Offset(0, 2), - ), - ], + // boxShadow: [ + // BoxShadow( + // // color: const Color(0xFF1CD381), + // blurRadius: 8, + // offset: const Offset(0, 2), + // ), + // ], ), child: TextField( controller: controller, maxLines: maxLines, minLines: minLines, - style: const TextStyle( + style: TextStyle( fontSize: 16, - color: Colors.black87, + color: getThemeColors(context)['textPrimary'], height: 1.4, ), decoration: InputDecoration( hintText: hint, hintStyle: TextStyle( - color: Colors.grey.shade500, + color: getThemeColors(context)['background'], fontSize: 14, ), border: OutlineInputBorder( @@ -316,7 +312,7 @@ class _MintNftCoordinatesPageState extends State { ), contentPadding: const EdgeInsets.all(20), filled: true, - fillColor: Colors.transparent, + fillColor: getThemeColors(context)['background'], ), ), ), @@ -340,17 +336,17 @@ class _MintNftCoordinatesPageState extends State { ), child: Icon( Icons.preview, - color: const Color(0xFF1CD381), + color: primaryGreenColor, size: 20, ), ), const SizedBox(width: 12), - const Text( + Text( 'Live Preview', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, - color: Color(0xFF1CD381), + color: primaryGreenColor, ), ), ], diff --git a/lib/pages/mint_nft/mint_nft_images.dart b/lib/pages/mint_nft/mint_nft_images.dart index 22397cd..1090913 100644 --- a/lib/pages/mint_nft/mint_nft_images.dart +++ b/lib/pages/mint_nft/mint_nft_images.dart @@ -4,10 +4,10 @@ import 'package:go_router/go_router.dart'; import 'package:image_picker/image_picker.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/mint_nft_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/logger.dart'; import 'package:tree_planting_protocol/utils/services/ipfs_services.dart'; import 'package:tree_planting_protocol/widgets/basic_scaffold.dart'; -import 'package:tree_planting_protocol/widgets/nft_display_utils/tree_nft_view_details_with_map.dart'; class MultipleImageUploadPage extends StatefulWidget { const MultipleImageUploadPage({super.key}); @@ -161,10 +161,12 @@ class _MultipleImageUploadPageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Text( - 'Upload Images', - style: Theme.of(context).textTheme.titleLarge, - ), + Text('Upload Images', + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.bold, + color: Theme.of(context).colorScheme.onSurface, + )), const SizedBox(height: 20), Row( children: [ @@ -173,7 +175,10 @@ class _MultipleImageUploadPageState extends State { onPressed: _isUploading ? null : _pickAndUploadImages, icon: const Icon(Icons.add_photo_alternate), - label: const Text('Add Photos'), + label: Text( + 'Add Photos', + style: TextStyle(color: primaryGreenColor), + ), ), ), const SizedBox(width: 16), @@ -183,7 +188,8 @@ class _MultipleImageUploadPageState extends State { icon: const Icon(Icons.delete_sweep), label: const Text('Remove All'), style: ElevatedButton.styleFrom( - foregroundColor: Colors.red, + foregroundColor: + getThemeColors(context)['secondaryButton'], ), ), ], @@ -223,13 +229,15 @@ class _MultipleImageUploadPageState extends State { width: 120, height: 120, decoration: BoxDecoration( - color: Colors.black54, + color: getThemeColors( + context)['primary'], borderRadius: BorderRadius.circular(8), ), - child: const Center( + child: Center( child: CircularProgressIndicator( - color: Colors.white, + color: getThemeColors( + context)['primary'], ), ), ), @@ -238,14 +246,16 @@ class _MultipleImageUploadPageState extends State { width: 120, height: 120, decoration: BoxDecoration( - color: Colors.black26, + color: getThemeColors( + context)['secondary'], borderRadius: BorderRadius.circular(8), ), - child: const Center( + child: Center( child: Icon( Icons.pending, - color: Colors.white, + color: + getThemeColors(context)['icon'], size: 32, ), ), @@ -255,14 +265,16 @@ class _MultipleImageUploadPageState extends State { width: 120, height: 120, decoration: BoxDecoration( - color: Colors.green, + color: getThemeColors( + context)['primary'], borderRadius: BorderRadius.circular(8), ), - child: const Center( + child: Center( child: Icon( Icons.check_circle, - color: Colors.white, + color: + getThemeColors(context)['icon'], size: 32, ), ), @@ -274,14 +286,16 @@ class _MultipleImageUploadPageState extends State { padding: const EdgeInsets.symmetric( horizontal: 8, vertical: 4), decoration: BoxDecoration( - color: Colors.black54, + color: getThemeColors( + context)['secondaryBackground'], borderRadius: BorderRadius.circular(12), ), child: Text( '${index + 1}', - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: getThemeColors( + context)['textSecondary'], fontSize: 12, fontWeight: FontWeight.bold, ), @@ -334,7 +348,7 @@ class _MultipleImageUploadPageState extends State { ), ), const SizedBox(height: 16), - NewNFTMapWidget(), + // NewNFTMapWidget(), ], ), ), @@ -349,13 +363,13 @@ class _MultipleImageUploadPageState extends State { Icon( Icons.cloud_off, size: 64, - color: Colors.grey[400], + color: getThemeColors(context)['icon'], ), const SizedBox(height: 16), Text( 'No images uploaded yet', style: TextStyle( - color: Colors.grey[600], + color: getThemeColors(context)['textPrimary'], fontSize: 16, ), ), @@ -363,7 +377,7 @@ class _MultipleImageUploadPageState extends State { Text( 'Tap "Add Photos" to get started', style: TextStyle( - color: Colors.grey[500], + color: getThemeColors(context)['textPrimary'], fontSize: 14, ), ), @@ -378,7 +392,7 @@ class _MultipleImageUploadPageState extends State { margin: const EdgeInsets.only(bottom: 8), child: ListTile( leading: CircleAvatar( - backgroundColor: Colors.green, + backgroundColor: getThemeColors(context)['primary'], child: Text('${index + 1}'), ), title: Text( @@ -403,8 +417,9 @@ class _MultipleImageUploadPageState extends State { tooltip: 'View IPFS Hash', ), IconButton( - icon: - const Icon(Icons.delete, color: Colors.red), + icon: Icon(Icons.delete, + color: getThemeColors( + context)['secondaryButton']), onPressed: () => _removeUploadedHash(index), tooltip: 'Remove', ), diff --git a/lib/pages/mint_nft/submit_nft_page.dart b/lib/pages/mint_nft/submit_nft_page.dart index 019d34a..550386a 100644 --- a/lib/pages/mint_nft/submit_nft_page.dart +++ b/lib/pages/mint_nft/submit_nft_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/mint_nft_provider.dart'; import 'package:tree_planting_protocol/providers/wallet_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/widgets/basic_scaffold.dart'; import 'package:tree_planting_protocol/widgets/nft_display_utils/tree_nft_view_details_with_map.dart'; import 'package:tree_planting_protocol/utils/logger.dart'; @@ -28,7 +29,8 @@ class _SubmitNFTPageState extends State { return AlertDialog( title: Row( children: [ - const Icon(Icons.check_circle, color: Colors.green), + Icon(Icons.check_circle, + color: getThemeColors(context)['primary']), const SizedBox(width: 8), Text(title), ], @@ -52,7 +54,7 @@ class _SubmitNFTPageState extends State { return AlertDialog( title: Row( children: [ - const Icon(Icons.error, color: Colors.red), + Icon(Icons.error, color: getThemeColors(context)['error']), const SizedBox(width: 8), Text(title), ], @@ -131,16 +133,16 @@ class _SubmitNFTPageState extends State { margin: const EdgeInsets.all(16), padding: const EdgeInsets.all(16), decoration: BoxDecoration( - color: Colors.green.shade50, + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.green.shade200), + border: Border.all(color: getThemeColors(context)['primaryBorder']!), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ - Icon(Icons.receipt_long, color: Colors.green.shade700), + Icon(Icons.receipt_long, color: getThemeColors(context)['icon']!), const SizedBox(width: 8), const Text( "Last Transaction:", @@ -186,16 +188,17 @@ class _SubmitNFTPageState extends State { margin: const EdgeInsets.all(16), padding: const EdgeInsets.all(16), decoration: BoxDecoration( - color: Colors.red.shade50, + color: getThemeColors(context)['error']!, borderRadius: BorderRadius.circular(8), - border: Border.all(color: Colors.red.shade200), + border: Border.all(color: getThemeColors(context)['error']!), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ - Icon(Icons.error_outline, color: Colors.red.shade700), + Icon(Icons.error_outline, + color: getThemeColors(context)['error']!), const SizedBox(width: 8), const Text( "Error:", @@ -210,7 +213,7 @@ class _SubmitNFTPageState extends State { Text( errorMessage!, style: TextStyle( - color: Colors.red.shade700, + color: getThemeColors(context)['error']!, fontSize: 14, ), ), @@ -229,9 +232,7 @@ class _SubmitNFTPageState extends State { children: [ const NewNFTMapWidget(), const SizedBox(height: 30), - _buildErrorInfo(), - Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: SizedBox( @@ -269,12 +270,8 @@ class _SubmitNFTPageState extends State { ), ), ), - const SizedBox(height: 16), - - // Transaction info display _buildTransactionInfo(), - const SizedBox(height: 16), ], ), diff --git a/lib/pages/organisations_pages/user_organisations_page.dart b/lib/pages/organisations_pages/user_organisations_page.dart new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lib/pages/organisations_pages/user_organisations_page.dart @@ -0,0 +1 @@ + diff --git a/lib/pages/register_user_page.dart b/lib/pages/register_user_page.dart index 357c338..1048c7e 100644 --- a/lib/pages/register_user_page.dart +++ b/lib/pages/register_user_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/wallet_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/services/contract_write_functions.dart'; import 'package:tree_planting_protocol/utils/services/ipfs_services.dart'; import 'package:tree_planting_protocol/widgets/basic_scaffold.dart'; @@ -62,7 +63,7 @@ class _RegisterUserPageState extends State { return AlertDialog( title: Row( children: [ - const Icon(Icons.error, color: Colors.red), + Icon(Icons.error, color: getThemeColors(context)['error']), const SizedBox(width: 8), Text(title), ], @@ -179,34 +180,29 @@ class _RegisterUserPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ const SizedBox(height: 20), - const Text( + Text( "Enter your details! Fellow Tree Planter!!", style: TextStyle( fontSize: 28, fontWeight: FontWeight.bold, - color: Color(0xFF1CD381), + color: getThemeColors(context)['primary'], ), textAlign: TextAlign.center, ), const SizedBox(height: 40), - - // Name Field _buildFormField( controller: nameController, label: 'Name', icon: Icons.person, hint: 'Enter your full name', maxLines: 1, + context: context, ), const SizedBox(height: 30), - - // Profile Photo Section _buildProfilePhotoSection(), - const SizedBox(height: 40), - // Error Message if (_errorMessage != null && _errorMessage!.isNotEmpty) Container( padding: const EdgeInsets.all(12), @@ -218,12 +214,14 @@ class _RegisterUserPageState extends State { ), child: Row( children: [ - Icon(Icons.error_outline, color: Colors.red.shade600), + Icon(Icons.error_outline, + color: getThemeColors(context)['error']), const SizedBox(width: 8), Expanded( child: Text( _errorMessage!, - style: TextStyle(color: Colors.red.shade600), + style: + TextStyle(color: getThemeColors(context)['error']), ), ), ], @@ -237,21 +235,21 @@ class _RegisterUserPageState extends State { child: ElevatedButton( onPressed: _isLoading || _isUploading ? null : _registerUser, style: ElevatedButton.styleFrom( - backgroundColor: const Color(0xFF1CD381), - foregroundColor: Colors.white, + backgroundColor: getThemeColors(context)['primary'], + foregroundColor: getThemeColors(context)['background'], shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(16), ), elevation: 2, ), child: _isLoading - ? const SizedBox( + ? SizedBox( height: 24, width: 24, child: CircularProgressIndicator( strokeWidth: 2, - valueColor: - AlwaysStoppedAnimation(Colors.white), + valueColor: AlwaysStoppedAnimation( + getThemeColors(context)['textPrimary']!), ), ) : const Text( @@ -281,19 +279,19 @@ class _RegisterUserPageState extends State { color: const Color(0xFF1CD381), borderRadius: BorderRadius.circular(8), ), - child: const Icon( + child: Icon( Icons.camera_alt, - color: Color(0xFF1CD381), + color: getThemeColors(context)['icon'], size: 18, ), ), const SizedBox(width: 8), - const Text( + Text( 'Profile Photo', style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, - color: Color(0xFF1CD381), + color: getThemeColors(context)['primary'], ), ), ], @@ -308,12 +306,12 @@ class _RegisterUserPageState extends State { color: Colors.white, borderRadius: BorderRadius.circular(16), border: Border.all( - color: const Color(0xFFFAEB96), + color: getThemeColors(context)['secondaryBorder']!, width: 2, ), boxShadow: [ BoxShadow( - color: const Color(0xFF1CD381), + color: getThemeColors(context)['primary']!, blurRadius: 8, offset: const Offset(0, 2), ), @@ -328,17 +326,18 @@ class _RegisterUserPageState extends State { Widget _buildPhotoContent() { if (_isUploading) { - return const Column( + return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation(Color(0xFF1CD381)), + valueColor: AlwaysStoppedAnimation( + getThemeColors(context)['primary']!), ), SizedBox(height: 16), Text( 'Uploading to IPFS...', style: TextStyle( - color: Color(0xFF1CD381), + color: getThemeColors(context)['primary']!, fontWeight: FontWeight.w500, ), ), @@ -367,9 +366,9 @@ class _RegisterUserPageState extends State { color: Colors.black54, shape: BoxShape.circle, ), - child: const Icon( + child: Icon( Icons.check, - color: Colors.white, + color: getThemeColors(context)['icon']!, size: 16, ), ), @@ -384,10 +383,10 @@ class _RegisterUserPageState extends State { color: Colors.black54, borderRadius: BorderRadius.circular(12), ), - child: const Text( + child: Text( 'Tap to change photo', style: TextStyle( - color: Colors.white, + color: getThemeColors(context)['textPrimary'], fontSize: 12, ), textAlign: TextAlign.center, @@ -404,14 +403,14 @@ class _RegisterUserPageState extends State { Icon( Icons.add_a_photo_outlined, size: 48, - color: Colors.grey.shade400, + color: getThemeColors(context)['icon']!, ), const SizedBox(height: 16), Text( 'Tap to select profile photo', style: TextStyle( fontSize: 16, - color: Colors.grey.shade600, + color: getThemeColors(context)['textPrimary'], fontWeight: FontWeight.w500, ), ), @@ -420,7 +419,7 @@ class _RegisterUserPageState extends State { 'This field is required', style: TextStyle( fontSize: 12, - color: Colors.grey.shade500, + color: getThemeColors(context)['textPrimary'], ), ), ], @@ -435,6 +434,7 @@ Widget _buildFormField({ required IconData icon, int maxLines = 1, int? minLines, + required BuildContext context, }) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -444,22 +444,22 @@ Widget _buildFormField({ Container( padding: const EdgeInsets.all(6), decoration: BoxDecoration( - color: const Color(0xFF1CD381), + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(8), ), child: Icon( icon, - color: const Color(0xFF1CD381), + color: getThemeColors(context)['primary'], size: 18, ), ), const SizedBox(width: 8), Text( label, - style: const TextStyle( + style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, - color: Color(0xFF1CD381), + color: getThemeColors(context)['primary']!, ), ), ], @@ -467,15 +467,15 @@ Widget _buildFormField({ const SizedBox(height: 12), Container( decoration: BoxDecoration( - color: Colors.white, + color: getThemeColors(context)['background']!, borderRadius: BorderRadius.circular(16), border: Border.all( - color: const Color(0xFFFAEB96), + color: getThemeColors(context)['border']!, width: 2, ), boxShadow: [ BoxShadow( - color: const Color(0xFF1CD381), + color: getThemeColors(context)['shadow']!, blurRadius: 8, offset: const Offset(0, 2), ), @@ -485,15 +485,15 @@ Widget _buildFormField({ controller: controller, maxLines: maxLines, minLines: minLines, - style: const TextStyle( + style: TextStyle( fontSize: 16, - color: Colors.black87, + color: getThemeColors(context)['textPrimary']!, height: 1.4, ), decoration: InputDecoration( hintText: hint, hintStyle: TextStyle( - color: Colors.grey.shade500, + color: getThemeColors(context)['textSecondary']!, fontSize: 14, ), border: OutlineInputBorder( diff --git a/lib/pages/tree_details_page.dart b/lib/pages/tree_details_page.dart index 47604ae..a4e7ae3 100644 --- a/lib/pages/tree_details_page.dart +++ b/lib/pages/tree_details_page.dart @@ -1,11 +1,12 @@ // ignore_for_file: use_build_context_synchronously - import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/wallet_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/logger.dart'; import 'package:tree_planting_protocol/utils/services/contract_read_services.dart'; import 'package:tree_planting_protocol/utils/services/contract_write_functions.dart'; +import 'package:tree_planting_protocol/utils/services/conversion_functions.dart'; import 'package:tree_planting_protocol/utils/services/ipfs_services.dart'; import 'package:tree_planting_protocol/widgets/basic_scaffold.dart'; import 'package:tree_planting_protocol/widgets/map_widgets/static_map_display_widget.dart'; @@ -38,12 +39,6 @@ class _TreeDetailsPageState extends State { loadTreeDetails(); } - static int _toInt(dynamic value) { - if (value is BigInt) return value.toInt(); - if (value is int) return value; - return int.tryParse(value.toString()) ?? 0; - } - Future loadTreeDetails() async { final walletProvider = Provider.of(context, listen: false); loggedInUser = walletProvider.currentAddress.toString(); @@ -52,7 +47,7 @@ class _TreeDetailsPageState extends State { }); final result = await ContractReadFunctions.getTreeNFTInfo( walletProvider: walletProvider, - id: _toInt(widget.treeId), + id: toInt(widget.treeId), offset: TREE_VERIFIERS_OFFSET, limit: TREE_VERIFIERS_LIMIT); if (result.success && result.data != null) { @@ -60,7 +55,6 @@ class _TreeDetailsPageState extends State { final List verifiersData = result.data['verifiers'] ?? []; final String owner = result.data['owner'].toString(); treeDetails = Tree.fromContractData(treesData, verifiersData, owner); - logger.d("Verifiers data: $verifiersData"); canVerify = true; for (var verifier in verifiersData) { if (verifier[0].toString().toLowerCase() == @@ -70,7 +64,6 @@ class _TreeDetailsPageState extends State { } } } - logger.d("Tree Details hot: ${treeDetails?.verifiers}"); setState(() { _isLoading = false; }); @@ -96,8 +89,10 @@ class _TreeDetailsPageState extends State { ), clipBehavior: Clip.antiAlias, child: StaticCoordinatesMap( - lat: (treeDetails!.latitude / 1e6) - 90.0, - lng: (treeDetails!.longitude / 1e6) - 180.0, + lat: (treeDetails!.latitude / 1e6) - + 90.0, // Data stored on the contract is positive in all cases (needs to be converted) + lng: (treeDetails!.longitude / 1e6) - + 180.0, // Data stored on the contract is positive in all cases (needs to be converted) ), ), ); @@ -121,15 +116,17 @@ class _TreeDetailsPageState extends State { height: 30, decoration: BoxDecoration( border: Border.all(width: 2.0), - color: const Color.fromARGB(255, 28, 211, 129), + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(8.0), ), child: Center( child: Text( ((treeDetails!.latitude / 1e6) - 90.0).toStringAsFixed(6), textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 9, height: 1, color: Colors.white), + style: TextStyle( + fontSize: 9, + height: 1, + color: getThemeColors(context)['textPrimary']), ), ), ), @@ -149,8 +146,10 @@ class _TreeDetailsPageState extends State { ((treeDetails!.longitude / 1e6) - 180.0) .toStringAsFixed(6), textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 9, height: 1, color: Colors.black), + style: TextStyle( + fontSize: 9, + height: 1, + color: getThemeColors(context)['textPrimary']), ), ), ), @@ -169,8 +168,10 @@ class _TreeDetailsPageState extends State { child: Text( (treeDetails!.species.toString()), textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 9, height: 1, color: Colors.white), + style: TextStyle( + fontSize: 9, + height: 1, + color: getThemeColors(context)['textPrimary']), ), ), ), @@ -198,17 +199,13 @@ class _TreeDetailsPageState extends State { margin: const EdgeInsets.symmetric(vertical: 16.0), padding: const EdgeInsets.all(16.0), decoration: BoxDecoration( - gradient: LinearGradient( - colors: canVerify - ? [Colors.green.shade400, Colors.green.shade600] - : [Colors.grey.shade300, Colors.grey.shade400], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), + color: canVerify + ? getThemeColors(context)['primary'] + : getThemeColors(context)['secondary'], borderRadius: BorderRadius.circular(12.0), boxShadow: [ BoxShadow( - color: Colors.black, + color: getThemeColors(context)['textPrimary']!, blurRadius: 8, offset: const Offset(0, 4), ), @@ -218,14 +215,14 @@ class _TreeDetailsPageState extends State { children: [ Icon( canVerify ? Icons.verified : Icons.lock, - color: Colors.white, + color: getThemeColors(context)['textPrimary']!, size: 32, ), const SizedBox(height: 8), Text( canVerify ? "Tree Verification" : "Verification Disabled", - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: getThemeColors(context)['textPrimary']!, fontSize: 18, fontWeight: FontWeight.bold, ), @@ -235,8 +232,8 @@ class _TreeDetailsPageState extends State { canVerify ? "Confirm this tree's authenticity" : "You cannot verify this tree", - style: const TextStyle( - color: Colors.white70, + style: TextStyle( + color: getThemeColors(context)['textPrimary'], fontSize: 14, ), textAlign: TextAlign.center, @@ -249,9 +246,10 @@ class _TreeDetailsPageState extends State { } : null, style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - foregroundColor: - canVerify ? Colors.green.shade600 : Colors.grey, + backgroundColor: getThemeColors(context)['background'], + foregroundColor: canVerify + ? getThemeColors(context)['primary'] + : getThemeColors(context)['secondary'], padding: const EdgeInsets.symmetric( horizontal: 32, vertical: 12), shape: RoundedRectangleBorder( @@ -297,9 +295,10 @@ class _TreeDetailsPageState extends State { width: double.infinity, padding: const EdgeInsets.all(16.0), decoration: BoxDecoration( - color: Colors.grey.shade50, + color: getThemeColors(context)['background'], borderRadius: BorderRadius.circular(12.0), - border: Border.all(color: Colors.grey.shade200), + border: Border.all( + color: getThemeColors(context)['primaryBorder']!, width: 1.5), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -309,16 +308,16 @@ class _TreeDetailsPageState extends State { style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, - color: Colors.grey.shade600, + color: getThemeColors(context)['textPrimary'], ), ), const SizedBox(height: 4), Text( value, - style: const TextStyle( + style: TextStyle( fontSize: 16, fontWeight: FontWeight.w500, - color: Colors.black87, + color: getThemeColors(context)['textPrimary'], ), ), ], @@ -340,29 +339,19 @@ class _TreeDetailsPageState extends State { required String description, required List proofHashes, }) async { - logger.d("Starting tree verification process"); - logger.d("Logged in user: $loggedInUser"); - logger.d("Tree ID: ${treeDetails!.id}"); - logger.d("Description: $description"); - logger.d("Proof hashes: $proofHashes"); - try { - // Get wallet provider WalletProvider walletProvider = Provider.of(context, listen: false); - - // Validate wallet connection if (!walletProvider.isConnected) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: const Text("Please connect your wallet first"), - backgroundColor: Colors.orange.shade600, + backgroundColor: getThemeColors(context)['primary'], behavior: SnackBarBehavior.floating, ), ); return; } - ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Row( @@ -372,7 +361,8 @@ class _TreeDetailsPageState extends State { height: 20, child: CircularProgressIndicator( strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(Colors.white), + valueColor: AlwaysStoppedAnimation( + getThemeColors(context)['textPrimary']!), ), ), const SizedBox(width: 16), @@ -399,7 +389,8 @@ class _TreeDetailsPageState extends State { SnackBar( content: Row( children: [ - Icon(Icons.check_circle, color: Colors.white), + Icon(Icons.check_circle, + color: getThemeColors(context)['icon']), const SizedBox(width: 8), const Text("Tree verification submitted successfully!"), ], @@ -415,13 +406,13 @@ class _TreeDetailsPageState extends State { SnackBar( content: Row( children: [ - Icon(Icons.error, color: Colors.white), + Icon(Icons.error, color: getThemeColors(context)['error']), const SizedBox(width: 8), Expanded( child: Text("Verification failed: ${result.errorMessage}")), ], ), - backgroundColor: Colors.red.shade600, + backgroundColor: getThemeColors(context)['error'], behavior: SnackBarBehavior.floating, duration: const Duration(seconds: 5), ), @@ -454,7 +445,7 @@ class _TreeDetailsPageState extends State { Expanded(child: Text(errorMessage)), ], ), - backgroundColor: Colors.red.shade600, + backgroundColor: getThemeColors(context)['error'], behavior: SnackBarBehavior.floating, duration: const Duration(seconds: 5), ), @@ -526,9 +517,9 @@ class _VerificationModalState extends State<_VerificationModal> { Future _pickImage() async { if (_selectedImages.length >= 3) { ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( + SnackBar( content: Text("Maximum 3 images allowed"), - backgroundColor: Colors.orange, + backgroundColor: getThemeColors(context)['secondary']!, ), ); return; @@ -551,9 +542,9 @@ class _VerificationModalState extends State<_VerificationModal> { Future _takePhoto() async { if (_selectedImages.length >= 3) { ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Maximum 3 images allowed"), - backgroundColor: Colors.orange, + SnackBar( + content: const Text("Maximum 3 images allowed"), + backgroundColor: getThemeColors(context)['secondary']!, ), ); return; @@ -610,7 +601,7 @@ class _VerificationModalState extends State<_VerificationModal> { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text("Error uploading images: $e"), - backgroundColor: Colors.red, + backgroundColor: getThemeColors(context)['error'], ), ); } finally { @@ -787,8 +778,9 @@ class _VerificationModalState extends State<_VerificationModal> { onTap: () => _removeImage(index), child: Container( padding: const EdgeInsets.all(2), - decoration: const BoxDecoration( - color: Colors.red, + decoration: BoxDecoration( + color: + getThemeColors(context)['error'], shape: BoxShape.circle, ), child: const Icon( @@ -810,7 +802,7 @@ class _VerificationModalState extends State<_VerificationModal> { Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( - color: Colors.blue.shade50, + color: getThemeColors(context)['background'], borderRadius: BorderRadius.circular(8), ), child: Row( @@ -821,7 +813,7 @@ class _VerificationModalState extends State<_VerificationModal> { child: CircularProgressIndicator( strokeWidth: 2, valueColor: AlwaysStoppedAnimation( - Colors.blue.shade600), + getThemeColors(context)['primary']), ), ), const SizedBox(width: 12), @@ -842,7 +834,8 @@ class _VerificationModalState extends State<_VerificationModal> { onPressed: () => Navigator.pop(context), child: Text( "Cancel", - style: TextStyle(color: Colors.grey.shade600), + style: TextStyle( + color: getThemeColors(context)['textPrimary']), ), ), ), @@ -866,8 +859,8 @@ class _VerificationModalState extends State<_VerificationModal> { ); }, style: ElevatedButton.styleFrom( - backgroundColor: Colors.green.shade600, - foregroundColor: Colors.white, + backgroundColor: getThemeColors(context)['primary'], + foregroundColor: getThemeColors(context)['background'], padding: const EdgeInsets.symmetric(vertical: 12), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), diff --git a/lib/providers/wallet_provider.dart b/lib/providers/wallet_provider.dart index 9cd3772..971f1c5 100644 --- a/lib/providers/wallet_provider.dart +++ b/lib/providers/wallet_provider.dart @@ -193,7 +193,7 @@ class WalletProvider extends ChangeNotifier { _currentAddress = null; _currentChainId = null; notifyListeners(); - + try { await disconnectWallet(); final uri = await connectWallet(); // Return the URI diff --git a/lib/utils/constants/ui/color_constants.dart b/lib/utils/constants/ui/color_constants.dart new file mode 100644 index 0000000..927a4ec --- /dev/null +++ b/lib/utils/constants/ui/color_constants.dart @@ -0,0 +1,56 @@ +import 'dart:ui'; + +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:tree_planting_protocol/providers/theme_provider.dart'; + +Color primaryYellowColor = Color.fromARGB(255, 251, 251, 99); +Color primaryGreenColor = Color.fromARGB(255, 28, 211, 129); + +Map getThemeColors(BuildContext context) { + final themeProvider = Provider.of(context, listen: false); + return { + 'primary': themeProvider.isDarkMode + ? Color.fromARGB(255, 0, 128, 70) + : Color.fromARGB(255, 28, 211, 129), + 'primaryLight': themeProvider.isDarkMode + ? Color.fromARGB(255, 0, 128, 70) + : Color.fromARGB(255, 28, 211, 129), + 'primaryBorder': themeProvider.isDarkMode + ? const Color.fromARGB(255, 1, 135, 12) + : const Color.fromARGB(255, 28, 211, 129), + 'BNWBorder': themeProvider.isDarkMode + ? const Color.fromARGB(255, 1, 135, 12) + : const Color.fromARGB(255, 28, 211, 129), + 'secondary': themeProvider.isDarkMode + ? Color.fromARGB(255, 131, 131, 36) + : Color.fromARGB(255, 251, 251, 99), + 'background': themeProvider.isDarkMode + ? const Color.fromARGB(255, 18, 18, 18) + : const Color.fromARGB(255, 255, 255, 255), + 'secondaryBackground': themeProvider.isDarkMode + ? const Color.fromARGB(255, 83, 81, 84) + : const Color.fromARGB(255, 210, 210, 210), + 'textPrimary': themeProvider.isDarkMode + ? const Color.fromARGB(255, 255, 255, 255) + : const Color.fromARGB(255, 0, 0, 0), + 'textSecondary': themeProvider.isDarkMode + ? const Color.fromARGB(255, 0, 0, 0) + : const Color.fromARGB(255, 255, 255, 255), + 'primaryButton': themeProvider.isDarkMode + ? Color.fromARGB(255, 0, 128, 70) + : Color.fromARGB(255, 28, 211, 129), + 'secondaryButton': themeProvider.isDarkMode + ? const Color.fromARGB(255, 255, 100, 100) + : const Color.fromARGB(255, 255, 0, 0), + 'icon': themeProvider.isDarkMode + ? const Color.fromARGB(255, 255, 255, 255) + : const Color.fromARGB(255, 0, 0, 0), + 'error': themeProvider.isDarkMode + ? const Color.fromARGB(255, 255, 100, 100) + : const Color.fromARGB(255, 255, 0, 0), + 'marker': themeProvider.isDarkMode + ? const Color.fromARGB(255, 255, 100, 100) + : const Color.fromARGB(255, 255, 0, 0), + }; +} diff --git a/lib/utils/services/conversion_functions.dart b/lib/utils/services/conversion_functions.dart new file mode 100644 index 0000000..bbd552f --- /dev/null +++ b/lib/utils/services/conversion_functions.dart @@ -0,0 +1,5 @@ +int toInt(dynamic value) { + if (value is BigInt) return value.toInt(); + if (value is int) return value; + return int.tryParse(value.toString()) ?? 0; +} diff --git a/lib/widgets/basic_scaffold.dart b/lib/widgets/basic_scaffold.dart index 4eebfa1..31857e6 100644 --- a/lib/widgets/basic_scaffold.dart +++ b/lib/widgets/basic_scaffold.dart @@ -16,16 +16,17 @@ class BaseScaffold extends StatelessWidget { final Widget? floatingActionButton; final bool extendBodyBehindAppBar; final bool showBottomNavigation; + final Widget? leading; - const BaseScaffold({ - super.key, - required this.body, - this.title, - this.actions, - this.floatingActionButton, - this.extendBodyBehindAppBar = false, - this.showBottomNavigation = true, - }); + const BaseScaffold( + {super.key, + required this.body, + this.title, + this.actions, + this.floatingActionButton, + this.extendBodyBehindAppBar = false, + this.showBottomNavigation = true, + this.leading}); @override Widget build(BuildContext context) { @@ -47,11 +48,6 @@ class BaseScaffold extends StatelessWidget { children: [ const CircularProgressIndicator(), const Text("Connecting"), - ElevatedButton( - onPressed: () async { - await provider.forceReconnect(); - }, - child: const Text("Force Reconnect")) ], )); } else if (!isWalletConnected) { @@ -63,7 +59,8 @@ class BaseScaffold extends StatelessWidget { } return Scaffold( - appBar: UniversalNavbar(title: title, actions: actions), + appBar: + UniversalNavbar(title: title, actions: actions, leading: leading), extendBodyBehindAppBar: extendBodyBehindAppBar, body: bodyContent, floatingActionButton: floatingActionButton, diff --git a/lib/widgets/map_widgets/flutter_map_widget.dart b/lib/widgets/map_widgets/flutter_map_widget.dart index ce2011d..936698f 100644 --- a/lib/widgets/map_widgets/flutter_map_widget.dart +++ b/lib/widgets/map_widgets/flutter_map_widget.dart @@ -3,6 +3,7 @@ import 'package:latlong2/latlong.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/mint_nft_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/logger.dart'; class CoordinatesMap extends StatefulWidget { @@ -37,7 +38,8 @@ class _CoordinatesMapState extends State { return Container( decoration: BoxDecoration( - border: Border.all(color: Colors.grey), + border: + Border.all(color: getThemeColors(context)['primaryBorder']!), borderRadius: BorderRadius.circular(8), ), child: ClipRRect( @@ -53,7 +55,7 @@ class _CoordinatesMapState extends State { Widget _buildErrorWidget() { return Container( - color: Colors.grey[100], + color: getThemeColors(context)['background'], child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -142,9 +144,9 @@ class _CoordinatesMapState extends State { point: LatLng(latitude, longitude), width: 80, height: 80, - child: const Icon( + child: Icon( Icons.location_pin, - color: Colors.red, + color: getThemeColors(context)['marker'], size: 40, ), ), @@ -172,13 +174,13 @@ class _CoordinatesMapState extends State { child: Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), decoration: BoxDecoration( - color: Colors.black, + color: getThemeColors(context)['background'], borderRadius: BorderRadius.circular(4), ), child: Text( "${latitude.toStringAsFixed(6)}, ${longitude.toStringAsFixed(6)}", - style: const TextStyle( - color: Colors.white, + style: TextStyle( + color: getThemeColors(context)['textPrimary'], fontSize: 10, ), ), @@ -191,11 +193,11 @@ class _CoordinatesMapState extends State { children: [ Container( decoration: BoxDecoration( - color: Colors.white, + color: getThemeColors(context)['background'], borderRadius: BorderRadius.circular(4), boxShadow: [ BoxShadow( - color: Colors.black, + color: getThemeColors(context)['BNWBorder']!, blurRadius: 4, offset: const Offset(0, 2), ), @@ -204,7 +206,7 @@ class _CoordinatesMapState extends State { child: Column( children: [ Material( - color: Colors.transparent, + color: getThemeColors(context)['BNWBorder'], child: InkWell( onTap: () { final currentZoom = _mapController.camera.zoom; @@ -222,9 +224,9 @@ class _CoordinatesMapState extends State { child: SizedBox( width: 40, height: 40, - child: const Icon( + child: Icon( Icons.add, - color: Colors.black87, + color: getThemeColors(context)['icon'], size: 20, ), ), @@ -232,7 +234,7 @@ class _CoordinatesMapState extends State { ), Container( height: 1, - color: Colors.grey[300], + color: getThemeColors(context)['background'], ), Material( color: Colors.transparent, @@ -253,9 +255,9 @@ class _CoordinatesMapState extends State { child: SizedBox( width: 40, height: 40, - child: const Icon( + child: Icon( Icons.remove, - color: Colors.black87, + color: getThemeColors(context)['icon'], size: 20, ), ), @@ -277,10 +279,10 @@ class _CoordinatesMapState extends State { color: Colors.blue, borderRadius: BorderRadius.circular(4), ), - child: const Text( + child: Text( "Tap to set location • Use zoom buttons or pinch to zoom", style: TextStyle( - color: Colors.white, + color: getThemeColors(context)['textPrimary'], fontSize: 11, ), textAlign: TextAlign.center, @@ -347,7 +349,7 @@ class _StaticDisplayMapState extends State { return Container( decoration: BoxDecoration( - border: Border.all(color: Colors.grey), + border: Border.all(color: getThemeColors(context)['primaryBorder']!), borderRadius: BorderRadius.circular(8), ), child: ClipRRect( @@ -361,7 +363,7 @@ class _StaticDisplayMapState extends State { Widget _buildErrorWidget() { return Container( - color: Colors.grey[100], + color: getThemeColors(context)['background'], child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -369,7 +371,7 @@ class _StaticDisplayMapState extends State { Icon( Icons.map_outlined, size: 60, - color: Colors.grey[400], + color: getThemeColors(context)['icon'], ), const SizedBox(height: 16), Text( @@ -377,7 +379,7 @@ class _StaticDisplayMapState extends State { style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, - color: Colors.grey[600], + color: getThemeColors(context)['textSecondary'], ), ), const SizedBox(height: 8), @@ -385,7 +387,7 @@ class _StaticDisplayMapState extends State { "Please use the coordinate fields below", style: TextStyle( fontSize: 12, - color: Colors.grey[500], + color: getThemeColors(context)['textPrimary'], ), textAlign: TextAlign.center, ), diff --git a/lib/widgets/map_widgets/static_map_display_widget.dart b/lib/widgets/map_widgets/static_map_display_widget.dart index 88e6d7c..fb5d8d9 100644 --- a/lib/widgets/map_widgets/static_map_display_widget.dart +++ b/lib/widgets/map_widgets/static_map_display_widget.dart @@ -34,7 +34,7 @@ class _StaticCoordinatesMapState extends State { final double longitude = widget.lng; return Container( - height: 200, // Fixed height for consistency + height: 200, decoration: BoxDecoration( border: Border.all(color: Colors.grey.shade300), borderRadius: BorderRadius.circular(12), diff --git a/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart b/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart index 5a91a90..e8886d2 100644 --- a/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart +++ b/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart @@ -3,6 +3,7 @@ import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/wallet_provider.dart'; import 'package:tree_planting_protocol/providers/theme_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/logger.dart'; import 'package:tree_planting_protocol/utils/services/contract_write_functions.dart'; @@ -274,21 +275,6 @@ void _copyToClipboard(String text, BuildContext context) { ); } -Map _getThemeColors(BuildContext context) { - final themeProvider = Provider.of(context); - return { - 'primary': themeProvider.isDarkMode - ? const Color.fromARGB(255, 1, 135, 12) - : const Color.fromARGB(255, 28, 211, 129), - 'primaryLight': themeProvider.isDarkMode - ? const Color.fromARGB(255, 1, 135, 12) - : const Color.fromARGB(255, 28, 211, 129), - 'primaryBorder': themeProvider.isDarkMode - ? const Color.fromARGB(255, 1, 135, 12) - : const Color.fromARGB(255, 28, 211, 129), - }; -} - Future _removeVerifier(Verifier verifier, BuildContext context, Tree? treeDetails, Function loadTreeDetails) async { logger.d("Removing verifier: ${verifier.address}"); @@ -342,7 +328,7 @@ Widget treeVerifiersSection(String? loggedInUser, Tree? treeDetails, logger.d("treeDetails?.verifiers: ${treeDetails?.verifiers}"); logger.d("verifiers length: ${treeDetails?.verifiers.length}"); - final themeColors = _getThemeColors(context); + final themeColors = getThemeColors(context); if (treeDetails?.verifiers == null || treeDetails!.verifiers.isEmpty) { logger.d("No verifiers found, showing empty state"); @@ -351,22 +337,22 @@ Widget treeVerifiersSection(String? loggedInUser, Tree? treeDetails, margin: const EdgeInsets.symmetric(vertical: 16.0), padding: const EdgeInsets.all(16.0), decoration: BoxDecoration( - color: Colors.grey.shade50, + color: getThemeColors(context)['background']!, borderRadius: BorderRadius.circular(12.0), - border: Border.all(color: Colors.grey.shade200), + border: Border.all(color: getThemeColors(context)['border']!), ), child: Column( children: [ Icon( Icons.group_off, - color: Colors.grey.shade400, + color: getThemeColors(context)['icon'], size: 32, ), const SizedBox(height: 8), Text( "No Verifiers Yet", style: TextStyle( - color: Colors.grey.shade600, + color: getThemeColors(context)['textPrimary'], fontSize: 16, fontWeight: FontWeight.w500, ), @@ -375,7 +361,7 @@ Widget treeVerifiersSection(String? loggedInUser, Tree? treeDetails, Text( "This tree hasn't been verified by anyone", style: TextStyle( - color: Colors.grey.shade500, + color: getThemeColors(context)['textPrimary']!, fontSize: 14, ), ), @@ -383,9 +369,6 @@ Widget treeVerifiersSection(String? loggedInUser, Tree? treeDetails, ), ); } - - logger.d( - "Rendering verifiers section with ${treeDetails.verifiers.length} verifiers"); final isOwner = treeDetails.owner == loggedInUser; return Container( @@ -393,7 +376,7 @@ Widget treeVerifiersSection(String? loggedInUser, Tree? treeDetails, margin: const EdgeInsets.symmetric(vertical: 16.0), padding: const EdgeInsets.all(16.0), decoration: BoxDecoration( - color: themeColors['primaryLight'], + color: themeColors['primary'], borderRadius: BorderRadius.circular(12.0), border: Border.all(color: themeColors['primaryBorder']!), ), @@ -404,33 +387,18 @@ Widget treeVerifiersSection(String? loggedInUser, Tree? treeDetails, children: [ Icon( Icons.verified_user, - color: themeColors['primary'], + color: primaryYellowColor, size: 24, ), const SizedBox(width: 8), Text( "Tree Verifiers", style: TextStyle( - color: themeColors['primary'], + color: getThemeColors(context)['textPrimary']!, fontSize: 18, fontWeight: FontWeight.bold, ), ), - const Spacer(), - Container( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), - decoration: BoxDecoration( - color: themeColors['primary']!, - borderRadius: BorderRadius.circular(12), - ), - child: Text( - "${treeDetails.verifiers.length}", - style: TextStyle( - color: themeColors['primary'], - fontWeight: FontWeight.bold, - ), - ), - ), ], ), const SizedBox(height: 12), @@ -457,7 +425,7 @@ Widget treeVerifiersSection(String? loggedInUser, Tree? treeDetails, Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, Function loadTreeDetails, Tree? treeDetails, BuildContext context) { - final themeColors = _getThemeColors(context); + final themeColors = getThemeColors(context); return Container( margin: const EdgeInsets.only(bottom: 8.0), @@ -475,7 +443,7 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(12.0), - border: Border.all(color: themeColors['primaryBorder']!), + border: Border.all(color: primaryYellowColor), boxShadow: [ BoxShadow( color: themeColors['primaryLight']!, @@ -539,18 +507,16 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, Icon( Icons.copy, size: 12, - color: themeColors['primary']!, + color: Colors.black, ), ], ), ), - const SizedBox(width: 8), if (verifier.proofHashes.isNotEmpty) Container( padding: const EdgeInsets.symmetric( horizontal: 6, vertical: 2), decoration: BoxDecoration( - color: themeColors['primary']!, borderRadius: BorderRadius.circular(8), ), child: Row( @@ -559,14 +525,15 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, Icon( Icons.photo_library, size: 10, - color: themeColors['primary'], + color: getThemeColors(context)['icon'], ), const SizedBox(width: 2), Text( "${verifier.proofHashes.length}", style: TextStyle( fontSize: 10, - color: themeColors['primary'], + color: getThemeColors( + context)['textPrimary'], fontWeight: FontWeight.w600, ), ), @@ -588,7 +555,7 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, verifier.formattedTimestamp, style: TextStyle( fontSize: 11, - color: Colors.grey.shade600, + color: getThemeColors(context)['textPrimary'], ), ), ], @@ -624,7 +591,7 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, decoration: BoxDecoration( color: Colors.red.shade500, shape: BoxShape.circle, - border: Border.all(color: Colors.white, width: 2), + border: Border.all(width: 2), boxShadow: [ BoxShadow( color: Colors.black, @@ -633,9 +600,9 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, ), ], ), - child: const Icon( + child: Icon( Icons.close, - color: Colors.white, + color: getThemeColors(context)['icon'], size: 16, ), ), @@ -647,6 +614,7 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, ); } +// verifier info modal void _showVerifierDetailsModal( Verifier verifier, BuildContext context, Map themeColors) { final screenSize = MediaQuery.of(context).size; @@ -701,7 +669,7 @@ void _showVerifierDetailsModal( style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, - color: themeColors['primary'], + color: Colors.black, ), ), ), @@ -724,14 +692,16 @@ void _showVerifierDetailsModal( Row( children: [ Icon(Icons.account_circle, - color: Colors.grey.shade600, size: 16), + color: getThemeColors(context)['icon'], + size: 16), const SizedBox(width: 6), Text( "Verifier Address", style: TextStyle( fontSize: 12, fontWeight: FontWeight.w600, - color: Colors.grey.shade700, + color: + getThemeColors(context)['textPrimary']!, ), ), ], @@ -744,7 +714,7 @@ void _showVerifierDetailsModal( width: double.infinity, padding: const EdgeInsets.all(8), decoration: BoxDecoration( - color: themeColors['primaryLight'], + color: themeColors['primary'], borderRadius: BorderRadius.circular(6), border: Border.all( color: themeColors['primaryBorder']!), @@ -764,7 +734,7 @@ void _showVerifierDetailsModal( Icon( Icons.copy, size: 16, - color: themeColors['primary'], + color: getThemeColors(context)['icon'], ), ], ), @@ -788,7 +758,8 @@ void _showVerifierDetailsModal( Row( children: [ Icon(Icons.photo_library, - color: Colors.grey.shade600, size: 20), + color: getThemeColors(context)['icon'], + size: 20), const SizedBox(width: 8), Text( "Proof Images (${verifier.proofHashes.length})", @@ -978,7 +949,7 @@ void _showRemoveVerifierDialog( ), title: Row( children: [ - Icon(Icons.warning, color: Colors.orange.shade600), + Icon(Icons.warning, color: getThemeColors(context)['icon']), const SizedBox(width: 8), const Text("Remove Verifier"), ], @@ -1040,7 +1011,7 @@ void _showRemoveVerifierDialog( Icon( Icons.copy, size: 14, - color: themeColors['primary'], + color: getThemeColors(context)['icon'], ), ], ), @@ -1072,7 +1043,7 @@ void _showRemoveVerifierDialog( "This action:", style: TextStyle( fontWeight: FontWeight.w600, - color: Colors.grey.shade700, + color: getThemeColors(context)['textPrimary'], ), ), _buildRemovalPoint("• Will require gas fees"), diff --git a/lib/widgets/nft_display_utils/tree_nft_view_details_with_map.dart b/lib/widgets/nft_display_utils/tree_nft_view_details_with_map.dart index bb9e6cb..66af69a 100644 --- a/lib/widgets/nft_display_utils/tree_nft_view_details_with_map.dart +++ b/lib/widgets/nft_display_utils/tree_nft_view_details_with_map.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/mint_nft_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/widgets/map_widgets/flutter_map_widget.dart'; class NewNFTMapWidget extends StatefulWidget { @@ -61,10 +62,10 @@ class _NewNFTMapWidgetState extends State { decoration: BoxDecoration( border: Border.all(color: Colors.green, width: 2), borderRadius: BorderRadius.circular(12.0), - color: Colors.white, + color: getThemeColors(context)['background'], boxShadow: [ BoxShadow( - color: Colors.green, + color: getThemeColors(context)['primary']!, blurRadius: 8, offset: const Offset(0, 2), ), @@ -142,7 +143,7 @@ class _NewNFTMapWidgetState extends State { style: TextStyle( fontSize: fontSize, fontWeight: FontWeight.w600, - color: Colors.green.shade700, + color: getThemeColors(context)['textPrimary']!, ), ), const SizedBox(height: 4), @@ -158,7 +159,7 @@ class _NewNFTMapWidgetState extends State { value, style: TextStyle( fontSize: fontSize, - color: Colors.grey.shade800, + color: getThemeColors(context)['textPrimary']!, height: isDescription ? 1.4 : 1.2, ), softWrap: true, diff --git a/lib/widgets/nft_display_utils/tree_nft_view_widget.dart b/lib/widgets/nft_display_utils/tree_nft_view_widget.dart index b8fff3f..c02bfc6 100644 --- a/lib/widgets/nft_display_utils/tree_nft_view_widget.dart +++ b/lib/widgets/nft_display_utils/tree_nft_view_widget.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/mint_nft_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; class NewNFTWidget extends StatefulWidget { const NewNFTWidget({super.key}); @@ -18,9 +19,10 @@ class _NewNFTWidgetState extends State { constraints: const BoxConstraints(maxWidth: 350), padding: const EdgeInsets.all(16.0), decoration: BoxDecoration( - border: Border.all(color: Colors.green, width: 2), + border: Border.all( + color: getThemeColors(context)['primaryBorder']!, width: 2), borderRadius: BorderRadius.circular(8.0), - color: Colors.white, + color: getThemeColors(context)['background']!, ), child: Consumer( builder: (ctx, provider, _) { diff --git a/lib/widgets/nft_display_utils/user_nfts_widget.dart b/lib/widgets/nft_display_utils/user_nfts_widget.dart index 4bd0bc2..df526db 100644 --- a/lib/widgets/nft_display_utils/user_nfts_widget.dart +++ b/lib/widgets/nft_display_utils/user_nfts_widget.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/wallet_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/logger.dart'; import 'package:tree_planting_protocol/utils/services/contract_read_services.dart'; @@ -383,10 +384,10 @@ class _UserNftsWidgetState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Icon( + Icon( Icons.error_outline, size: 64, - color: Colors.red, + color: getThemeColors(context)['error'], ), const SizedBox(height: 16), Text( @@ -409,10 +410,10 @@ class _UserNftsWidgetState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Icon( + Icon( Icons.eco, size: 64, - color: Colors.grey, + color: getThemeColors(context)['icon'], ), const SizedBox(height: 16), Text( diff --git a/lib/widgets/profile_widgets/profile_section_widget.dart b/lib/widgets/profile_widgets/profile_section_widget.dart index 82aeeb1..b8c6ee6 100644 --- a/lib/widgets/profile_widgets/profile_section_widget.dart +++ b/lib/widgets/profile_widgets/profile_section_widget.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/wallet_provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/logger.dart'; import 'package:tree_planting_protocol/utils/services/contract_read_services.dart'; @@ -262,9 +263,9 @@ class _ProfileSectionWidgetState extends State { borderRadius: BorderRadius.circular(12), boxShadow: [ BoxShadow( - color: Colors.black12, // shadow color - blurRadius: 6, // shadow softness - offset: Offset(0, 3), // shadow position + color: Colors.black12, + blurRadius: 6, + offset: Offset(0, 3), ), ], ), @@ -486,14 +487,15 @@ class _ProfileSectionWidgetState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation(Colors.green.shade600), + valueColor: AlwaysStoppedAnimation( + getThemeColors(context)['primary']!), ), const SizedBox(height: 16), Text( 'Loading profile...', style: TextStyle( fontSize: 16, - color: Colors.green.shade700, + color: getThemeColors(context)['primary'], ), ), ], diff --git a/lib/widgets/wallet_not_connected_widget.dart b/lib/widgets/wallet_not_connected_widget.dart index 84d3d7f..cb044b4 100644 --- a/lib/widgets/wallet_not_connected_widget.dart +++ b/lib/widgets/wallet_not_connected_widget.dart @@ -1,26 +1,26 @@ import 'package:flutter/material.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; Widget buildWalletNotConnectedWidget(BuildContext context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Icon( + Icon( Icons.account_balance_wallet, size: 64, - color: Colors.grey, + color: getThemeColors(context)['icon'], ), const SizedBox(height: 16), - const Text( + Text( 'Please connect your wallet to view your NFTs', textAlign: TextAlign.center, style: TextStyle( fontSize: 16, - color: Colors.grey, + color: getThemeColors(context)['textPrimary'], ), ), const SizedBox(height: 16), - ], ), ); diff --git a/lib/widgets/wrong_chain_widget.dart b/lib/widgets/wrong_chain_widget.dart index b34cf3d..899f42b 100644 --- a/lib/widgets/wrong_chain_widget.dart +++ b/lib/widgets/wrong_chain_widget.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:tree_planting_protocol/providers/wallet_provider.dart'; import 'package:provider/provider.dart'; +import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/services/switch_chain_utils.dart'; Widget buildWrongChainWidget(BuildContext context) { @@ -8,19 +9,19 @@ Widget buildWrongChainWidget(BuildContext context) { return Center( child: Container( decoration: BoxDecoration( - color: Colors.white, + color: getThemeColors(context)['primary'], border: Border.all( - color: Colors.black, + color: getThemeColors(context)['border']!, width: 2, ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Icon( + Icon( Icons.account_balance_wallet, size: 64, - color: Colors.grey, + color: getThemeColors(context)['icon'], ), const SizedBox(height: 16), Text( @@ -38,7 +39,7 @@ Widget buildWrongChainWidget(BuildContext context) { }, style: ButtonStyle( backgroundColor: WidgetStateProperty.all( - const Color.fromARGB(255, 28, 211, 129), + getThemeColors(context)['primary']!, ), ), child: const Text('Switch Chain'), From 277fe79e21a37728f5e751932f79e8162961dd2f Mon Sep 17 00:00:00 2001 From: IronJam11 Date: Sat, 20 Sep 2025 22:15:35 +0530 Subject: [PATCH 3/5] refactor: profile section colour consistency --- lib/pages/mint_nft/mint_nft_coordinates.dart | 2 +- lib/pages/mint_nft/mint_nft_details.dart | 1 + lib/utils/constants/ui/color_constants.dart | 2 - .../tree_nft_details_verifiers_widget.dart | 104 ++++++------------ 4 files changed, 33 insertions(+), 76 deletions(-) diff --git a/lib/pages/mint_nft/mint_nft_coordinates.dart b/lib/pages/mint_nft/mint_nft_coordinates.dart index 6e2fc1d..0d30f52 100644 --- a/lib/pages/mint_nft/mint_nft_coordinates.dart +++ b/lib/pages/mint_nft/mint_nft_coordinates.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:http/http.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/mint_nft_provider.dart'; import 'package:tree_planting_protocol/utils/constants/route_constants.dart'; @@ -408,6 +407,7 @@ class _MintNftCoordinatesPageState extends State { ); } + // ignore: unused_element Widget _buildLocationStatus() { final isManual = _userHasManuallySetCoordinates; final isLoading = _isLoadingLocation; diff --git a/lib/pages/mint_nft/mint_nft_details.dart b/lib/pages/mint_nft/mint_nft_details.dart index 1be8fd5..88f70f1 100644 --- a/lib/pages/mint_nft/mint_nft_details.dart +++ b/lib/pages/mint_nft/mint_nft_details.dart @@ -320,6 +320,7 @@ class _MintNftCoordinatesPageState extends State { ); } + // ignore: unused_element Widget _buildPreviewSection() { return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/utils/constants/ui/color_constants.dart b/lib/utils/constants/ui/color_constants.dart index 927a4ec..11b8246 100644 --- a/lib/utils/constants/ui/color_constants.dart +++ b/lib/utils/constants/ui/color_constants.dart @@ -1,5 +1,3 @@ -import 'dart:ui'; - import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/theme_provider.dart'; diff --git a/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart b/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart index e8886d2..fa01414 100644 --- a/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart +++ b/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:tree_planting_protocol/providers/wallet_provider.dart'; -import 'package:tree_planting_protocol/providers/theme_provider.dart'; import 'package:tree_planting_protocol/utils/constants/ui/color_constants.dart'; import 'package:tree_planting_protocol/utils/logger.dart'; import 'package:tree_planting_protocol/utils/services/contract_write_functions.dart'; @@ -97,14 +96,8 @@ class Tree { factory Tree.fromContractData( List userData, List verifiers, String owner) { - logger.d("=== Tree.fromContractData ==="); - logger.d("User data: $userData"); - logger.d("Verifiers raw data: $verifiers"); - logger.d("Owner: $owner"); try { final parsedVerifiers = _parseVerifiers(verifiers); - logger.d("Parsed verifiers count: ${parsedVerifiers.length}"); - final tree = Tree( id: _toInt(userData[0]), latitude: _toInt(userData[1]), @@ -127,12 +120,8 @@ class Tree { verifiers: parsedVerifiers, owner: owner, ); - - logger.d( - "Tree created successfully with ${tree.verifiers.length} verifiers"); return tree; } catch (e) { - logger.e("Error creating Tree from contract data: $e"); return Tree( id: 0, latitude: 0, @@ -162,18 +151,11 @@ class Tree { static List _parseVerifiers(List verifiersData) { List verifiers = []; - - logger.d("Parsing verifiers data: $verifiersData"); - logger.d("Verifiers data length: ${verifiersData.length}"); - for (int i = 0; i < verifiersData.length; i++) { var verifierEntry = verifiersData[i]; - logger.d( - "Verifier entry $i: $verifierEntry (type: ${verifierEntry.runtimeType})"); try { if (verifierEntry is String) { - logger.d("Parsing string verifier: $verifierEntry"); verifiers.add(Verifier( address: verifierEntry, timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000, @@ -182,11 +164,7 @@ class Tree { isActive: true, verificationId: i, )); - logger.d("Successfully parsed string verifier $i"); } else if (verifierEntry is List) { - logger.d("Verifier entry $i length: ${verifierEntry.length}"); - logger.d("Verifier entry $i contents: $verifierEntry"); - if (verifierEntry.isNotEmpty) { if (verifierEntry.length == 1) { verifiers.add(Verifier( @@ -293,7 +271,7 @@ Future _removeVerifier(Verifier verifier, BuildContext context, messenger.showSnackBar( SnackBar( content: const Text("Verifier removed successfully!"), - backgroundColor: Colors.green.shade600, + backgroundColor: getThemeColors(context)['primary'], behavior: SnackBarBehavior.floating, ), ); @@ -302,7 +280,7 @@ Future _removeVerifier(Verifier verifier, BuildContext context, messenger.showSnackBar( SnackBar( content: Text("Failed to remove verifier: ${result.errorMessage}"), - backgroundColor: Colors.red.shade600, + backgroundColor: getThemeColors(context)['error'], behavior: SnackBarBehavior.floating, ), ); @@ -313,7 +291,7 @@ Future _removeVerifier(Verifier verifier, BuildContext context, ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text("Error: $e"), - backgroundColor: Colors.red.shade600, + backgroundColor: getThemeColors(context)['error'], behavior: SnackBarBehavior.floating, ), ); @@ -323,11 +301,6 @@ Future _removeVerifier(Verifier verifier, BuildContext context, Widget treeVerifiersSection(String? loggedInUser, Tree? treeDetails, Function loadTreeDetails, BuildContext context) { - logger.d("=== treeVerifiersSection ==="); - logger.d("treeDetails: $treeDetails"); - logger.d("treeDetails?.verifiers: ${treeDetails?.verifiers}"); - logger.d("verifiers length: ${treeDetails?.verifiers.length}"); - final themeColors = getThemeColors(context); if (treeDetails?.verifiers == null || treeDetails!.verifiers.isEmpty) { @@ -458,14 +431,7 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, width: 44, height: 44, decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - themeColors['primary']!, - themeColors['primary']! - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(22), boxShadow: [ BoxShadow( @@ -497,10 +463,11 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, children: [ Text( verifier.shortAddress, - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.w600, fontSize: 14, fontFamily: 'monospace', + color: getThemeColors(context)['textPrimary'] ), ), const SizedBox(width: 6), @@ -582,14 +549,14 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, child: InkWell( onTap: () { _showRemoveVerifierDialog(verifier, index, context, - treeDetails, loadTreeDetails, themeColors); + treeDetails, loadTreeDetails); }, borderRadius: BorderRadius.circular(15), child: Container( width: 30, height: 30, decoration: BoxDecoration( - color: Colors.red.shade500, + color: getThemeColors(context)['error'], shape: BoxShape.circle, border: Border.all(width: 2), boxShadow: [ @@ -614,7 +581,6 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, ); } -// verifier info modal void _showVerifierDetailsModal( Verifier verifier, BuildContext context, Map themeColors) { final screenSize = MediaQuery.of(context).size; @@ -646,19 +612,12 @@ void _showVerifierDetailsModal( width: 40, height: 40, decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - themeColors['primary']!, - themeColors['primary']! - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(20), ), - child: const Icon( + child: Icon( Icons.verified_user, - color: Colors.white, + color: getThemeColors(context)['icon'], size: 20, ), ), @@ -669,13 +628,13 @@ void _showVerifierDetailsModal( style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, - color: Colors.black, + color: getThemeColors(context)['textPrimary'], ), ), ), IconButton( onPressed: () => Navigator.pop(context), - icon: Icon(Icons.close, color: themeColors['primary']), + icon: Icon(Icons.close, color: getThemeColors(context)['icon']), ), ], ), @@ -714,10 +673,10 @@ void _showVerifierDetailsModal( width: double.infinity, padding: const EdgeInsets.all(8), decoration: BoxDecoration( - color: themeColors['primary'], + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(6), border: Border.all( - color: themeColors['primaryBorder']!), + color: getThemeColors(context)['primaryBorder']!), ), child: Row( children: [ @@ -747,11 +706,11 @@ void _showVerifierDetailsModal( "Verified On", verifier.formattedTimestamp, Icons.access_time, - themeColors), + context), const SizedBox(height: 12), if (verifier.description.isNotEmpty) ...[ _buildDetailRow("Description", verifier.description, - Icons.description, themeColors), + Icons.description, context), const SizedBox(height: 12), ], if (verifier.proofHashes.isNotEmpty) ...[ @@ -766,7 +725,7 @@ void _showVerifierDetailsModal( style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, - color: Colors.grey.shade700, + color:getThemeColors(context)['textPrimary'], ), ), ], @@ -828,12 +787,12 @@ void _showVerifierDetailsModal( padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: verifier.isActive - ? themeColors['primary']! + ? getThemeColors(context)['primary']! : Colors.red.shade50, borderRadius: BorderRadius.circular(8), border: Border.all( color: verifier.isActive - ? themeColors['primary']! + ? getThemeColors(context)['primary']! : Colors.red.shade200, ), ), @@ -844,7 +803,7 @@ void _showVerifierDetailsModal( ? Icons.check_circle : Icons.cancel, color: verifier.isActive - ? themeColors['primary'] + ? getThemeColors(context)['primary'] : Colors.red.shade600, size: 20, ), @@ -855,7 +814,7 @@ void _showVerifierDetailsModal( : "Inactive Verification", style: TextStyle( color: verifier.isActive - ? themeColors['primary'] + ? getThemeColors(context)['primaryText'] : Colors.red.shade700, fontWeight: FontWeight.w600, ), @@ -875,7 +834,7 @@ void _showVerifierDetailsModal( child: ElevatedButton( onPressed: () => Navigator.pop(context), style: ElevatedButton.styleFrom( - backgroundColor: themeColors['primary'], + backgroundColor: getThemeColors(context)['background'], foregroundColor: Colors.white, padding: const EdgeInsets.symmetric(vertical: 12), shape: RoundedRectangleBorder( @@ -895,20 +854,20 @@ void _showVerifierDetailsModal( } Widget _buildDetailRow( - String label, String value, IconData icon, Map themeColors) { + String label, String value, IconData icon, BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ - Icon(icon, color: Colors.grey.shade600, size: 16), + Icon(icon, color: getThemeColors(context)['icon'], size: 16), const SizedBox(width: 6), Text( label, style: TextStyle( fontSize: 12, fontWeight: FontWeight.w600, - color: Colors.grey.shade700, + color: getThemeColors(context)['textPrimary'], ), ), ], @@ -918,7 +877,7 @@ Widget _buildDetailRow( width: double.infinity, padding: const EdgeInsets.all(8), decoration: BoxDecoration( - color: Colors.grey.shade50, + color: getThemeColors(context)['background'], borderRadius: BorderRadius.circular(6), ), child: Text( @@ -938,8 +897,7 @@ void _showRemoveVerifierDialog( int index, BuildContext context, Tree? treeDetails, - Function loadTreeDetails, - Map themeColors) { + Function loadTreeDetails) { showDialog( context: context, builder: (BuildContext context) { @@ -966,9 +924,9 @@ void _showRemoveVerifierDialog( Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( - color: themeColors['primaryLight'], + color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(8), - border: Border.all(color: themeColors['primaryBorder']!), + border: Border.all(color: getThemeColors(context)['primaryBorder']!), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -995,7 +953,7 @@ void _showRemoveVerifierDialog( color: Colors.white, borderRadius: BorderRadius.circular(6), border: - Border.all(color: themeColors['primaryBorder']!), + Border.all(color: getThemeColors(context)['primaryBorder']!), ), child: Row( children: [ From 2c5a3e81718d1d96b9c33938b3e93083ea1a18c5 Mon Sep 17 00:00:00 2001 From: IronJam11 Date: Sat, 20 Sep 2025 23:50:17 +0530 Subject: [PATCH 4/5] fix: null operator check --- .../tree_nft_details_verifiers_widget.dart | 17 +++-------------- lib/widgets/wrong_chain_widget.dart | 4 ++-- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart b/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart index fa01414..32186d3 100644 --- a/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart +++ b/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart @@ -765,12 +765,12 @@ void _showVerifierDetailsModal( (context, child, loadingProgress) { if (loadingProgress == null) return child; return Container( - color: Colors.grey.shade100, + color: getThemeColors(context)['background'], child: Center( child: CircularProgressIndicator( strokeWidth: 2, valueColor: AlwaysStoppedAnimation( - themeColors['primary']), + getThemeColors(context)['primary']), ), ), ); @@ -808,17 +808,6 @@ void _showVerifierDetailsModal( size: 20, ), const SizedBox(width: 8), - Text( - verifier.isActive - ? "Active Verification" - : "Inactive Verification", - style: TextStyle( - color: verifier.isActive - ? getThemeColors(context)['primaryText'] - : Colors.red.shade700, - fontWeight: FontWeight.w600, - ), - ), ], ), ), @@ -841,7 +830,7 @@ void _showVerifierDetailsModal( borderRadius: BorderRadius.circular(8), ), ), - child: const Text("Close"), + child: Text("Close", style: TextStyle(color: getThemeColors(context)['textPrimary']),), ), ), ), diff --git a/lib/widgets/wrong_chain_widget.dart b/lib/widgets/wrong_chain_widget.dart index 899f42b..0927598 100644 --- a/lib/widgets/wrong_chain_widget.dart +++ b/lib/widgets/wrong_chain_widget.dart @@ -9,9 +9,9 @@ Widget buildWrongChainWidget(BuildContext context) { return Center( child: Container( decoration: BoxDecoration( - color: getThemeColors(context)['primary'], + color: getThemeColors(context)['background'], border: Border.all( - color: getThemeColors(context)['border']!, + color: getThemeColors(context)['primaryBorder']!, width: 2, ), ), From a4ae941f3a128afc23d3f6d2b92531935aaa98c6 Mon Sep 17 00:00:00 2001 From: IronJam11 Date: Sat, 20 Sep 2025 23:57:00 +0530 Subject: [PATCH 5/5] fix: dart formatting issue --- .../tree_nft_details_verifiers_widget.dart | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart b/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart index 32186d3..87d2502 100644 --- a/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart +++ b/lib/widgets/nft_display_utils/tree_nft_details_verifiers_widget.dart @@ -464,11 +464,11 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, Text( verifier.shortAddress, style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 14, - fontFamily: 'monospace', - color: getThemeColors(context)['textPrimary'] - ), + fontWeight: FontWeight.w600, + fontSize: 14, + fontFamily: 'monospace', + color: getThemeColors( + context)['textPrimary']), ), const SizedBox(width: 6), Icon( @@ -548,8 +548,8 @@ Widget _buildVerifierCard(Verifier verifier, int index, bool canRemove, color: Colors.transparent, child: InkWell( onTap: () { - _showRemoveVerifierDialog(verifier, index, context, - treeDetails, loadTreeDetails); + _showRemoveVerifierDialog( + verifier, index, context, treeDetails, loadTreeDetails); }, borderRadius: BorderRadius.circular(15), child: Container( @@ -634,7 +634,8 @@ void _showVerifierDetailsModal( ), IconButton( onPressed: () => Navigator.pop(context), - icon: Icon(Icons.close, color: getThemeColors(context)['icon']), + icon: Icon(Icons.close, + color: getThemeColors(context)['icon']), ), ], ), @@ -676,7 +677,8 @@ void _showVerifierDetailsModal( color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(6), border: Border.all( - color: getThemeColors(context)['primaryBorder']!), + color: getThemeColors( + context)['primaryBorder']!), ), child: Row( children: [ @@ -725,7 +727,7 @@ void _showVerifierDetailsModal( style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, - color:getThemeColors(context)['textPrimary'], + color: getThemeColors(context)['textPrimary'], ), ), ], @@ -765,12 +767,14 @@ void _showVerifierDetailsModal( (context, child, loadingProgress) { if (loadingProgress == null) return child; return Container( - color: getThemeColors(context)['background'], + color: getThemeColors( + context)['background'], child: Center( child: CircularProgressIndicator( strokeWidth: 2, valueColor: AlwaysStoppedAnimation( - getThemeColors(context)['primary']), + getThemeColors( + context)['primary']), ), ), ); @@ -830,7 +834,11 @@ void _showVerifierDetailsModal( borderRadius: BorderRadius.circular(8), ), ), - child: Text("Close", style: TextStyle(color: getThemeColors(context)['textPrimary']),), + child: Text( + "Close", + style: TextStyle( + color: getThemeColors(context)['textPrimary']), + ), ), ), ), @@ -881,12 +889,8 @@ Widget _buildDetailRow( ); } -void _showRemoveVerifierDialog( - Verifier verifier, - int index, - BuildContext context, - Tree? treeDetails, - Function loadTreeDetails) { +void _showRemoveVerifierDialog(Verifier verifier, int index, + BuildContext context, Tree? treeDetails, Function loadTreeDetails) { showDialog( context: context, builder: (BuildContext context) { @@ -915,7 +919,8 @@ void _showRemoveVerifierDialog( decoration: BoxDecoration( color: getThemeColors(context)['primary'], borderRadius: BorderRadius.circular(8), - border: Border.all(color: getThemeColors(context)['primaryBorder']!), + border: Border.all( + color: getThemeColors(context)['primaryBorder']!), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -941,8 +946,8 @@ void _showRemoveVerifierDialog( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(6), - border: - Border.all(color: getThemeColors(context)['primaryBorder']!), + border: Border.all( + color: getThemeColors(context)['primaryBorder']!), ), child: Row( children: [