Skip to content

Commit

Permalink
feat: improve layout tabs in home screen. Create ProfileScreen with i…
Browse files Browse the repository at this point in the history
…nputs and image picker
  • Loading branch information
dnielopez committed Oct 24, 2023
1 parent 234e6ad commit 17adee7
Show file tree
Hide file tree
Showing 13 changed files with 466 additions and 47 deletions.
Binary file added assets/images/icons/add_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/icons/no_user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:dinogrow/pages/mini-games/mini_games.dart';
import 'package:dinogrow/pages/mini-games/up/up.dart';
import 'package:dinogrow/pages/mini-games/up/down.dart';
import 'package:dinogrow/pages/mini-games/coming_soon.dart';
import 'package:dinogrow/pages/profile.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -71,6 +72,11 @@ final GoRouter _router = GoRouter(routes: <GoRoute>[
builder: (context, state) {
return const ComingSoonScreen();
}),
GoRoute(
path: '/profile',
builder: (context, state) {
return const ProfileScreen();
}),
]);

class MyApp extends StatelessWidget {
Expand Down
133 changes: 89 additions & 44 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:go_router/go_router.dart';
import 'package:solana/solana.dart';

import 'package:dinogrow/pages/my-dinogrow/my_dinogrow.dart';
Expand All @@ -16,6 +17,7 @@ class HomeScreen extends StatefulWidget {
}

class _HomeScreenState extends State<HomeScreen> {
String? nickName;
String? _publicKey;
String? _balance;
SolanaClient? client;
Expand All @@ -41,47 +43,70 @@ class _HomeScreenState extends State<HomeScreen> {
flexibleSpace: Column(
children: [
SizedBox(height: statusBarHeight),
Card(
color: Colors.white,
shadowColor: Colors.white,
elevation: 9,
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
const Text(
'User: ',
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.black),
),
const SizedBox(width: 3),
Expanded(
child: Text(
_publicKey == null
? 'Loading...'
: '${_publicKey!.substring(0, 6)}...${_publicKey!.substring(_publicKey!.length - 6, _publicKey!.length)}',
maxLines: 1,
style: const TextStyle(color: Colors.black),
)),
const SizedBox(width: 12),
const Text(
'Balance: ',
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.black),
),
const SizedBox(width: 3),
Text(
_balance != null
? double.parse(_balance ?? '0').toStringAsFixed(2)
: 'Loading...',
maxLines: 1,
style: const TextStyle(color: Colors.black)),
const SizedBox(width: 3),
const Text('SOL',
GestureDetector(
onTap: () {
GoRouter.of(context).push('/profile');
},
child: Card(
color: Colors.white,
shadowColor: Colors.white,
elevation: 9,
child: Padding(
padding: const EdgeInsets.only(
top: 6, bottom: 6, left: 12, right: 12),
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(42),
child: Image.asset(
'assets/images/icons/no_user.png',
width: 40,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
children: [
Text(
(nickName ?? '(No nickname)'),
maxLines: 1,
style: const TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16),
),
const SizedBox(height: 3),
Text(
_publicKey == null
? 'Loading...'
: '${_publicKey!.substring(0, 6)}...${_publicKey!.substring(_publicKey!.length - 6, _publicKey!.length)}',
maxLines: 1,
style: const TextStyle(
color: Colors.black, fontSize: 10),
)
],
)),
const SizedBox(width: 12),
const Text(
'Balance: ',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black)),
],
fontWeight: FontWeight.bold, color: Colors.black),
),
const SizedBox(width: 3),
Text(
_balance != null
? double.parse(_balance ?? '0')
.toStringAsFixed(2)
: 'Loading...',
maxLines: 1,
style: const TextStyle(color: Colors.black)),
const SizedBox(width: 3),
const Text('SOL',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black)),
],
),
),
),
),
Expand All @@ -92,20 +117,40 @@ class _HomeScreenState extends State<HomeScreen> {
indicatorSize: TabBarIndicatorSize.tab,
tabs: [
Tab(
icon: Icon(Icons.videogame_asset),
height: 60,
icon: Icon(
Icons.videogame_asset,
size: 18,
),
text: 'Games',
iconMargin: EdgeInsets.all(6),
),
Tab(
icon: Icon(Icons.emoji_events),
height: 60,
icon: Icon(
Icons.emoji_events,
size: 18,
),
text: 'Ranking',
iconMargin: EdgeInsets.all(6),
),
Tab(
icon: Icon(Icons.pets),
height: 60,
icon: Icon(
Icons.pets,
size: 18,
),
text: 'My Dino',
iconMargin: EdgeInsets.all(6),
),
Tab(
icon: Icon(Icons.wallet),
height: 60,
icon: Icon(
Icons.wallet,
size: 18,
),
text: 'Wallet',
iconMargin: EdgeInsets.all(6),
),
],
),
Expand Down
4 changes: 1 addition & 3 deletions lib/pages/my-dinogrow/my_dinogrow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:go_router/go_router.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'package:solana/solana.dart';
import 'package:solana_common/utils/convert.dart';
import 'package:solana_web3/solana_web3.dart' as web3;
import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -378,7 +377,6 @@ class _MydinogrowScreenState extends State<MydinogrowScreen> {
String hdPath = dotenv.env['HD_PATH'].toString();
final walletdino = await solana.Ed25519HDKeyPair.fromSeedWithHdPath(
seed: keypair.secretKey, hdPath: hdPath);


final mainWalletSolana = await solana.Ed25519HDKeyPair.fromMnemonic(
mainWalletKey!,
Expand Down Expand Up @@ -508,7 +506,7 @@ class _MydinogrowScreenState extends State<MydinogrowScreen> {
final snackBar = SnackBar(
content: Text('Error: $e', style: const TextStyle(color: Colors.white)),
backgroundColor: Colors.red,
);
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
} finally {
if (mounted) {
Expand Down
Loading

0 comments on commit 17adee7

Please sign in to comment.