Skip to content

Commit 6c1b0e9

Browse files
Merge pull request #9 from StabilityNexus/UserProfilePage
Feat: User profile page
2 parents 91a1fc2 + 81672df commit 6c1b0e9

35 files changed

Lines changed: 4264 additions & 476 deletions

lib/components/bottom_navigation_widget.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class BottomNavigationWidget extends StatelessWidget {
1616
return i;
1717
}
1818
}
19-
return 0; // Default to first item if route not found
19+
return 0;
2020
}
2121

2222
@override
@@ -26,7 +26,7 @@ class BottomNavigationWidget extends StatelessWidget {
2626
type: BottomNavigationBarType.fixed,
2727
selectedItemColor: Theme.of(context).colorScheme.primary,
2828
unselectedItemColor: Theme.of(context).colorScheme.onSurfaceVariant,
29-
backgroundColor: Theme.of(context).colorScheme.surface,
29+
backgroundColor: const Color.fromARGB(255, 37, 236, 147),
3030
elevation: 8,
3131
onTap: (index) {
3232
final route = BottomNavConstants.items[index].route;
@@ -43,4 +43,4 @@ class BottomNavigationWidget extends StatelessWidget {
4343
}).toList(),
4444
);
4545
}
46-
}
46+
}

lib/components/universal_navbar.dart

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget {
5151
width: 36,
5252
height: 36,
5353
decoration: BoxDecoration(
54-
color: Colors.white.withOpacity(0.2),
54+
color: Colors.white,
5555
borderRadius: BorderRadius.circular(8),
5656
border: Border.all(
5757
color: Colors.white.withOpacity(0.3),
@@ -101,34 +101,34 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget {
101101
child: Row(
102102
mainAxisAlignment: MainAxisAlignment.end,
103103
children: [
104-
Container(
105-
width: 36,
106-
height: 36,
107-
decoration: BoxDecoration(
108-
color: Colors.white.withOpacity(0.2),
109-
borderRadius: BorderRadius.circular(8),
110-
border: Border.all(
111-
color: Colors.white.withOpacity(0.3),
112-
width: 1,
113-
),
114-
),
115-
child: IconButton(
116-
padding: EdgeInsets.zero,
117-
icon: Icon(
118-
themeProvider.isDarkMode
119-
? Icons.light_mode
120-
: Icons.dark_mode,
121-
color: Colors.white,
122-
size: 18,
123-
),
124-
onPressed: () {
125-
themeProvider.toggleTheme();
126-
},
127-
tooltip: themeProvider.isDarkMode
128-
? 'Switch to Light Mode'
129-
: 'Switch to Dark Mode',
130-
),
131-
),
104+
// Container(
105+
// width: 36,
106+
// height: 36,
107+
// decoration: BoxDecoration(
108+
// color: Colors.white.withOpacity(0.2),
109+
// borderRadius: BorderRadius.circular(8),
110+
// border: Border.all(
111+
// color: Colors.white.withOpacity(0.3),
112+
// width: 1,
113+
// ),
114+
// ),
115+
// child: IconButton(
116+
// padding: EdgeInsets.zero,
117+
// icon: Icon(
118+
// themeProvider.isDarkMode
119+
// ? Icons.light_mode
120+
// : Icons.dark_mode,
121+
// color: Colors.white,
122+
// size: 18,
123+
// ),
124+
// onPressed: () {
125+
// themeProvider.toggleTheme();
126+
// },
127+
// tooltip: themeProvider.isDarkMode
128+
// ? 'Switch to Light Mode'
129+
// : 'Switch to Dark Mode',
130+
// ),
131+
// ),
132132
const SizedBox(width: 6),
133133
if (actions != null) ...actions!,
134134
if (walletProvider.isConnected &&
@@ -238,7 +238,8 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget {
238238

239239
Widget _buildWalletMenu(BuildContext context, WalletProvider walletProvider) {
240240
return Container(
241-
constraints: const BoxConstraints(maxWidth: 100), // Limit max width
241+
constraints: const BoxConstraints(maxWidth: 100, minHeight: 20),
242+
// Limit max width
242243
decoration: BoxDecoration(
243244
color: Colors.white.withOpacity(0.95),
244245
borderRadius: BorderRadius.circular(16),
@@ -319,9 +320,7 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget {
319320
),
320321
);
321322
}
322-
}
323-
324-
else if (value == 'Switch Chain') {
323+
} else if (value == 'Switch Chain') {
325324
showChainSelector(context, walletProvider);
326325
}
327326
},
@@ -337,7 +336,8 @@ class UniversalNavbar extends StatelessWidget implements PreferredSizeWidget {
337336
const PopupMenuItem<String>(
338337
value: 'Switch Chain',
339338
child: ListTile(
340-
leading: Icon(Icons.switch_access_shortcut, color: Colors.green, size: 20),
339+
leading: Icon(Icons.switch_access_shortcut,
340+
color: Colors.green, size: 20),
341341
title: Text(
342342
'Switch Chain',
343343
style: TextStyle(color: Colors.green),

lib/components/wallet_connect_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@ class WalletConnectDialog extends StatelessWidget {
110110
],
111111
);
112112
}
113-
}
113+
}

lib/main.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import 'package:tree_planting_protocol/pages/home_page.dart';
66
import 'package:tree_planting_protocol/pages/mint_nft/mint_nft_details.dart';
77
import 'package:tree_planting_protocol/pages/mint_nft/mint_nft_images.dart';
88
import 'package:tree_planting_protocol/pages/mint_nft/submit_nft_page.dart';
9+
import 'package:tree_planting_protocol/pages/register_user_page.dart';
910
import 'package:tree_planting_protocol/pages/settings_page.dart';
11+
import 'package:tree_planting_protocol/pages/tree_details_page.dart';
1012
import 'package:tree_planting_protocol/pages/trees_page.dart';
1113
import 'package:tree_planting_protocol/pages/mint_nft/mint_nft_coordinates.dart';
1214

@@ -21,6 +23,7 @@ import 'package:tree_planting_protocol/utils/logger.dart';
2123
class NavigationService {
2224
static GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
2325
}
26+
2427
void main() async {
2528
try {
2629
await dotenv.load(fileName: ".env");
@@ -46,6 +49,13 @@ class MyApp extends StatelessWidget {
4649
return const HomePage();
4750
},
4851
),
52+
GoRoute(
53+
path: '/register-user',
54+
name: 'Register_user',
55+
builder: (BuildContext context, GoRouterState state) {
56+
return const RegisterUserPage();
57+
},
58+
),
4959
GoRoute(
5060
path: '/settings',
5161
name: 'settings_page',
@@ -59,14 +69,14 @@ class MyApp extends StatelessWidget {
5969
builder: (context, state) => const MintNftCoordinatesPage(),
6070
routes: [
6171
GoRoute(
62-
path: 'details',
72+
path: 'details',
6373
name: '${RouteConstants.mintNft}_details',
6474
builder: (BuildContext context, GoRouterState state) {
6575
return const MintNftDetailsPage();
6676
},
6777
),
6878
GoRoute(
69-
path: 'images',
79+
path: 'images',
7080
name: '${RouteConstants.mintNft}_images',
7181
builder: (BuildContext context, GoRouterState state) {
7282
return const MultipleImageUploadPage();
@@ -88,10 +98,11 @@ class MyApp extends StatelessWidget {
8898
},
8999
routes: [
90100
GoRoute(
91-
path: 'details',
101+
path: ':id',
92102
name: '${RouteConstants.allTrees}_details',
93103
builder: (BuildContext context, GoRouterState state) {
94-
return const AllTreesPage();
104+
final id = state.pathParameters['id']; // read the dynamic ID
105+
return TreeDetailsPage(treeId: id!);
95106
},
96107
),
97108
],

lib/models/wallet_chain_option.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ final List<WalletOption> walletOptionsList = [
3030
];
3131

3232
final Map<String, String> rpcUrls = {
33-
'11155111':
34-
'https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY',
33+
'11155111': 'https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY',
3534
'1': 'https://eth-mainnet.g.alchemy.com/v2/$ALCHEMY_API_KEY',
3635
};
3736

@@ -48,8 +47,7 @@ final Map<String, Map<String, dynamic>> chainInfoList = {
4847
},
4948
'11155111': {
5049
'name': 'Sepolia Testnet',
51-
'rpcUrl':
52-
'https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY',
50+
'rpcUrl': 'https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY',
5351
'nativeCurrency': {
5452
'name': 'Sepolia Ether',
5553
'symbol': 'SEP',

lib/pages/home_page.dart

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
import 'package:flutter/material.dart';
22
import 'package:go_router/go_router.dart';
3-
import 'package:tree_planting_protocol/widgets/basic_scaffold.dart';
3+
4+
import 'package:provider/provider.dart';
5+
import 'package:tree_planting_protocol/providers/wallet_provider.dart';
6+
47
import 'package:tree_planting_protocol/utils/constants/navbar_constants.dart';
58
import 'package:tree_planting_protocol/utils/constants/route_constants.dart';
69

10+
import 'package:tree_planting_protocol/widgets/basic_scaffold.dart';
11+
import 'package:tree_planting_protocol/widgets/profile_widgets/profile_section_widget.dart';
12+
import 'package:tree_planting_protocol/widgets/nft_display_utils/user_nfts_widget.dart';
13+
714
class HomePage extends StatelessWidget {
815
const HomePage({super.key});
916

1017
@override
1118
Widget build(BuildContext context) {
1219
return BaseScaffold(
1320
title: appName,
14-
body: Center(
15-
child: Column(
16-
mainAxisAlignment: MainAxisAlignment.center,
17-
children: [
18-
Text(
19-
'Welcome to the Tree Planting Protocol!',
20-
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
21-
color: Theme.of(context).colorScheme.onSurface,
22-
),
23-
textAlign: TextAlign.center,
24-
),
25-
const SizedBox(height: 32),
26-
const SizedBox(height: 16),
27-
ElevatedButton(
28-
onPressed: () {
29-
context.push(RouteConstants.allTreesPath);
30-
},
31-
child: const Text('Go to all trees page'),
21+
body: Consumer<WalletProvider>(
22+
builder: (context, walletProvider, child) {
23+
return SingleChildScrollView(
24+
child: Column(
25+
children: [
26+
SizedBox(width: 400, child: ProfileSectionWidget()),
27+
SizedBox(
28+
width: 400,
29+
height: 600,
30+
child: UserNftsWidget(
31+
isOwnerCalling: true,
32+
userAddress: walletProvider.currentAddress ?? ''),
33+
),
34+
],
3235
),
33-
],
34-
),
36+
);
37+
},
3538
),
3639
);
3740
}
38-
}
41+
}

0 commit comments

Comments
 (0)