Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>




<queries>
<package android:name="io.metamask"/>
<package android:name="com.wallet.crypto.trustapp"/>
<package android:name="io.gnosis.safe"/>
<package android:name="me.rainbow"/>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="wc" />
</intent>
</queries>
<application
android:label="tree_planting_protocol"
Expand Down Expand Up @@ -56,6 +57,13 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="treeplantingprotocol" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
Expand Down
91 changes: 72 additions & 19 deletions lib/components/universal_navbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Widget>? 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);
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -362,13 +366,43 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget {

Widget _buildConnectButton(
BuildContext context, WalletProvider walletProvider) {
// Determine the state and corresponding visual properties
Color backgroundColor;
Color borderColor;
Color textColor;
IconData iconData;
String buttonText;

if (walletProvider.isConnecting) {
backgroundColor = Colors.orange.shade50;
borderColor = Colors.orange;
textColor = Colors.orange.shade700;
iconData = Icons.sync;
buttonText = 'Retry';
// 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';
} else {
// Disconnected state
backgroundColor = Colors.white;
borderColor = Colors.green;
textColor = Colors.green.shade700;
iconData = Icons.account_balance_wallet;
buttonText = 'Connect';
}

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: [
Expand All @@ -384,12 +418,22 @@ 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) {
final uri = await walletProvider.forceReconnect();
if (uri != null && context.mounted) {
showDialog(
context: context,
builder: (context) => WalletConnectDialog(uri: uri),
);
}
} else {
final uri = await walletProvider.connectWallet();
if (uri != null && context.mounted) {
showDialog(
context: context,
builder: (context) => WalletConnectDialog(uri: uri),
);
}
}
},
child: Padding(
Expand All @@ -398,17 +442,26 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget {
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<Color>(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,
),
Expand Down
Loading