Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor/new-ui #3

Merged
merged 8 commits into from
Oct 5, 2023
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
82 changes: 73 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,80 @@
# dinogrow
# DINOGROW

A new Flutter project.
![DINOGROW Logo](https://github.com/sistemaseltigre/dinogrow/raw/master/assets/images/logo.jpeg)

DINOGROW is an exciting mobile game developed in Flutter that combines the fun of dinosaur games with the power of the Solana blockchain. In this game, players can create a new wallet on the Solana blockchain as their in-game identity, allowing them to interact with the blockchain quickly and transparently.

## Key Features

- Solana Login: Players can log in to the game and generate a new wallet on the Solana blockchain, which acts as their avatar in the game.
- NFTs and Paid Games: Players who own NFTs can participate in paid matches and compete for rewards. Rewards are divided among the top 3 players on the leaderboard every 24 hours.
- Offline Mode: DINOGROW allows players to enjoy the game without an internet connection. You can play anywhere and decide when to synchronize blockchain transactions later.
- Dinosaur Games: The project focuses on creating a series of dinosaur mini-games that interact with the Solana blockchain, providing a unique gaming experience.

## Objectives

- Hackathon Participation: Our main goal is to develop at least one dinosaur mini-game before the end of the Solana Hyperdrive Hackathon.

- Open Source: This project is entirely open source. Anyone can download and use it as a foundation for creating their own mobile blockchain game. We are using Flutter and Flutter Flame, along with the Solana and Solana Web3 libraries to ensure functionality and stability.

## Quicknode Integration

In this project, we utilize Quicknode and its NFT API to seamlessly access Solana NFTs. Quicknode provides a fast and easy way to interact with the Solana blockchain, enhancing the user experience.

## Set up .env

Create a .env File: You need to create a .env file at the root of your project directory. This file should contain the following two environment variables:
QUICKNODE_RPC_URL and QUICKNODE_RPC_WSS with the appropriate RPC URL and WebSocket URL that you want to use.

```bash
QUICKNODE_RPC_URL=https://your-quicknode-rpc-url.com
QUICKNODE_RPC_WSS=wss://your-quicknode-websocket-url.com
```

Note: These settings will enable your application to connect to Quicknode's Solana API for NFT functionality. If you use other RPCs, obtaining data from the nft may not work the same way.

Example .env content:

## Getting Started

This project is a starting point for a Flutter application.
If you want to try DINOGROW or contribute to the project, follow these steps:

- Clone the Repository: Clone this repository to your local machine using the following command:

```bash
git clone https://github.com/YourUsername/DINOGROW.git
```

- Install Dependencies: Make sure you have Flutter and the Solana and Solana Web3 libraries installed. Then, install the project's dependencies:

```bash
flutter pub get
```

- Run the Game: Start the game on your device or emulator with the following command:

```bash
flutter run
```

## Contributions

We welcome contributions from the community! If you'd like to collaborate on the project, please follow these guidelines:

Fork the repository.
Make your changes in a new branch.
Submit a pull request (PR) describing your changes concisely.

## License

This project is licensed under the MIT License. See the LICENSE file for more details.

## Contact

If you have any questions or suggestions, feel free to contact us:

A few resources to get you started if this is your first Flutter project:
Email: dinogrow@​yahoo.com

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
Twitter: @DIN0GR0W

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
We hope you enjoy DINOGROW, and we hope this project inspires others to create mobile SOLANA blockchain games. Have fun playing and developing!
16 changes: 11 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:go_router/go_router.dart';
import 'package:dinogrow/pages/generatePhrase.dart';
import 'package:dinogrow/pages/generate_phrase.dart';
import 'package:dinogrow/pages/home.dart';
import 'package:dinogrow/pages/inputPhrase.dart';
import 'package:dinogrow/pages/input_phrase.dart';
import 'package:dinogrow/pages/login.dart';
import 'package:dinogrow/pages/setupAccount.dart';
import 'package:dinogrow/pages/setupPassword.dart';
import 'package:dinogrow/pages/setup_account.dart';
import 'package:dinogrow/pages/setup_password.dart';
import 'package:dinogrow/pages/mini-games/mini_games.dart';
import 'package:dinogrow/pages/mini-games/up/up.dart';
import 'package:dinogrow/pages/mini-games/coming_soon.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -59,6 +60,11 @@ final GoRouter _router = GoRouter(routes: <GoRoute>[
builder: (context, state) {
return GameWidgetUp(game: UpGame());
}),
GoRoute(
path: '/mini_games/comming_soon',
builder: (context, state) {
return const ComingSoonScreen();
}),
]);

class MyApp extends StatelessWidget {
Expand All @@ -79,4 +85,4 @@ class MyApp extends StatelessWidget {
routerConfig: _router,
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import 'package:bip39/bip39.dart' as bip39;
import 'package:go_router/go_router.dart';

import 'package:dinogrow/pages/setup_password.dart';
import '../ui/widgets/widgets.dart';

class GeneratePhraseScreen extends StatefulWidget {
Expand Down Expand Up @@ -81,7 +82,14 @@ class _GeneratePhraseScreenState extends State<GeneratePhraseScreen> {
text: _copied ? 'Continue' : 'Go Back',
onPressed: _copied
? () {
GoRouter.of(context).push("/passwordSetup/$_mnemonic");
// GoRouter.of(context).push("/passwordSetup/$_mnemonic");
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) {
return SetupPasswordScreen(mnemonic: _mnemonic);
},
);
}
: () {
GoRouter.of(context).push("/");
Expand Down
166 changes: 92 additions & 74 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
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';
import 'package:dinogrow/pages/mini-games/mini_games.dart';
import 'package:dinogrow/pages/ranking/ranking.dart';
import 'package:dinogrow/pages/wallet/wallet.dart';

class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});

Expand All @@ -24,83 +28,97 @@ class _HomeScreenState extends State<HomeScreen> {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('DINOGROW'),
),
body: Padding(
padding: const EdgeInsets.all(16),
child: ListView(
children: [
// User card
Card(
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
children: [
const Text('User'),
Text(_publicKey == null
? 'Loading...'
: '${_publicKey!.substring(0, 4)}...${_publicKey!.substring(_publicKey!.length - 3, _publicKey!.length)}'),
Text(_balance ?? 'Loading...'),
],
),
),
),

// menu card
Card(
child: Padding(
padding: EdgeInsets.all(8),
child: Column(
children: [
TextButton(
child: Text('My Dinogrow'),
onPressed: () {
// My Dinos button
},
),
TextButton(
child: Text('Mini Games'),
onPressed: () {
GoRouter.of(context).push("/mini_games");
},
),
TextButton(
child: Text('Wallet'),
onPressed: () {
// wallet button
},
),
TextButton(
child: Text('Ranking'),
onPressed: () {
// Ranking button
},
)
],
return DefaultTabController(
length: 4,
child: Scaffold(
appBar: AppBar(
backgroundColor: const Color.fromRGBO(241, 189, 57, 1),
elevation: 6,
toolbarHeight: 120,
flexibleSpace: Column(
children: [
const SizedBox(height: 38),
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)}',
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 ?? 'Loading...',
style: const TextStyle(color: Colors.black)),
const SizedBox(width: 3),
const Text('SOL',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black)),
],
),
),
),
),

// logout card
Card(
child: Padding(
padding: EdgeInsets.all(8),
child: Row(
children: [
Text('Log Out'),
IconButton(
icon: Icon(Icons.logout),
onPressed: () {
GoRouter.of(context).push("/");
},
)
],
),
const TabBar(
unselectedLabelColor: Color.fromRGBO(34, 38, 59, 1),
labelColor: Colors.white,
indicatorColor: Colors.white,
indicatorSize: TabBarIndicatorSize.tab,
tabs: [
Tab(
icon: Icon(Icons.videogame_asset),
text: 'Games',
),
Tab(
icon: Icon(Icons.emoji_events),
text: 'Ranking',
),
Tab(
icon: Icon(Icons.pets),
text: 'My Dino',
),
Tab(
icon: Icon(Icons.wallet),
text: 'Wallet',
),
],
),
],
),
),
body: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/ui/intro_jungle_bg.png"),
fit: BoxFit.cover,
),
],
),
child: TabBarView(
children: [
const MiniGamesScreen(),
RankingScreen(),
const MydinogrowScreen(),
WalletScreen(address: _publicKey, balance: _balance),
],
),
),
),
);
Expand Down
11 changes: 9 additions & 2 deletions lib/pages/inputPhrase.dart → lib/pages/input_phrase.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:bip39/bip39.dart' as bip39;

import 'package:dinogrow/pages/setup_password.dart';
import '../ui/widgets/widgets.dart';

class InputPhraseScreen extends StatefulWidget {
Expand Down Expand Up @@ -126,7 +126,14 @@ class _InputPhraseScreenState extends State<InputPhraseScreen> {
String wordsString = _words.join(' ');
final t = bip39.validateMnemonic(wordsString);
if (t) {
GoRouter.of(context).push("/passwordSetup/$wordsString");
// GoRouter.of(context).push("/passwordSetup/$wordsString");
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) {
return SetupPasswordScreen(mnemonic: wordsString);
},
);
} else {
setState(() {
validationFailed = true;
Expand Down
Loading