Skip to content

Commit

Permalink
Merge pull request #8 from sistemaseltigre/feature/blockchain-services
Browse files Browse the repository at this point in the history
feature/blockchain-services
  • Loading branch information
dnielopez authored Oct 14, 2023
2 parents 1acdc54 + 540e6ea commit d184e23
Show file tree
Hide file tree
Showing 28 changed files with 1,560 additions and 494 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.history
.svn/
migrate_working_dir/
*.jks

# IntelliJ related
*.iml
Expand Down
22 changes: 20 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "com.example.dinogrow"
namespace "crypto.game.dinogrow"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

Expand All @@ -45,7 +51,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.dinogrow"
applicationId "crypto.game.dinogrow"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 23
Expand All @@ -54,8 +60,20 @@ android {
versionName flutterVersionName
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
release {
signingConfig signingConfigs.release
}
debug {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="DinoGrow"
android:name="${applicationName}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.dinogrow
package crypto.game.dinogrow

import io.flutter.embedding.android.FlutterActivity

Expand Down
Binary file added assets/images/up/maps/01/left_btn.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/up/maps/01/right_btn.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/up/thumb.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 @@ -9,6 +9,7 @@ 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/up/down.dart';
import 'package:dinogrow/pages/mini-games/coming_soon.dart';

void main() {
Expand Down Expand Up @@ -60,6 +61,11 @@ final GoRouter _router = GoRouter(routes: <GoRoute>[
builder: (context, state) {
return GameWidgetUp(game: UpGame());
}),
GoRoute(
path: '/mini_games/down',
builder: (context, state) {
return const GameWidgetDown();
}),
GoRoute(
path: '/mini_games/comming_soon',
builder: (context, state) {
Expand Down
117 changes: 59 additions & 58 deletions lib/pages/generate_phrase.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
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';
Expand Down Expand Up @@ -37,66 +36,68 @@ class _GeneratePhraseScreenState extends State<GeneratePhraseScreen> {
fit: BoxFit.cover,
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(height: 60),
Container(
color: Colors.orange[700],
padding: const EdgeInsets.all(8),
child: const Text(
'Important! Copy and save the recovery phrase in a secure location. This cannot be recovered later.',
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
child: Padding(
padding: const EdgeInsets.all(23),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(height: 60),
Container(
color: Colors.orange[700],
padding: const EdgeInsets.all(8),
child: const Text(
'Important! Copy and save the recovery phrase in a secure location. This cannot be recovered later.',
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
),
TextBoxWidget(text: _mnemonic),
IntroButtonWidget(
text: 'Copy phrase',
onPressed: () {
Clipboard.setData(ClipboardData(text: _mnemonic));
const snackBar = SnackBar(
content: Text('Copied!'),
);
TextBoxWidget(text: _mnemonic),
IntroButtonWidget(
text: 'Copy phrase',
onPressed: () {
Clipboard.setData(ClipboardData(text: _mnemonic));
const snackBar = SnackBar(
content: Text('Copied!'),
);

ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
),
Container(
decoration: const BoxDecoration(color: Colors.black),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Checkbox(
value: _copied,
onChanged: (value) {
setState(() {
_copied = value!;
});
},
),
const Text("I have stored the recovery phrase securely"),
],
)),
IntroButtonWidget(
text: _copied ? 'Continue' : 'Go Back',
onPressed: _copied
? () {
// GoRouter.of(context).push("/passwordSetup/$_mnemonic");
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) {
return SetupPasswordScreen(mnemonic: _mnemonic);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
),
Container(
decoration: const BoxDecoration(color: Colors.black),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Checkbox(
value: _copied,
onChanged: (value) {
setState(() {
_copied = value!;
});
},
);
}
: () {
GoRouter.of(context).push("/");
},
),
const SizedBox(height: 60),
],
),
const Text("I have stored the recovery phrase securely"),
],
)),
IntroButtonWidget(
text: 'Continue',
variant: _copied ? 'primary' : 'disabled',
onPressed: _copied
? () {
// GoRouter.of(context).push("/passwordSetup/$_mnemonic");
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (context) {
return SetupPasswordScreen(mnemonic: _mnemonic);
},
);
}
: () {},
),
const SizedBox(height: 60),
],
),
),
),
);
Expand Down
15 changes: 12 additions & 3 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class _HomeScreenState extends State<HomeScreen> {
String? _balance;
SolanaClient? client;
final storage = const FlutterSecureStorage();

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -66,7 +67,10 @@ class _HomeScreenState extends State<HomeScreen> {
fontWeight: FontWeight.bold, color: Colors.black),
),
const SizedBox(width: 3),
Text(_balance ?? 'Loading...',
Text(
_balance != null
? double.parse(_balance ?? '0').toStringAsFixed(2)
: 'Loading...',
style: const TextStyle(color: Colors.black)),
const SizedBox(width: 3),
const Text('SOL',
Expand Down Expand Up @@ -112,11 +116,16 @@ class _HomeScreenState extends State<HomeScreen> {
),
),
child: TabBarView(
physics: const NeverScrollableScrollPhysics(),
children: [
const MiniGamesScreen(),
RankingScreen(),
const MydinogrowScreen(),
WalletScreen(address: _publicKey, balance: _balance),
MydinogrowScreen(
address: _publicKey ?? '', getBalance: () => _getBalance()),
WalletScreen(
address: _publicKey ?? '',
balance: _balance,
getBalance: () => _getBalance()),
],
),
),
Expand Down
106 changes: 59 additions & 47 deletions lib/pages/input_phrase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class InputPhraseScreen extends StatefulWidget {

class _InputPhraseScreenState extends State<InputPhraseScreen> {
final _formKey = GlobalKey<FormState>();
final _words = List<String>.filled(12, '');
bool validationFailed = false;
var controllers =
List<TextEditingController>.generate(12, (i) => TextEditingController());
Expand Down Expand Up @@ -66,53 +65,57 @@ class _InputPhraseScreenState extends State<InputPhraseScreen> {
fit: BoxFit.cover,
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(height: 60),
const TextBoxWidget(text: 'Please enter your recovery phrase'),
Center(
child: Form(
key: _formKey,
child: SizedBox(
width: 300,
child: GridView.count(
padding: const EdgeInsets.all(3),
crossAxisSpacing: 10,
mainAxisSpacing: 3,
shrinkWrap: true,
crossAxisCount: 3,
children: List.generate(12, (index) {
return SizedBox(
height: 50,
child: TextFormField(
controller: controllers[index],
decoration: InputDecoration(
filled: true,
fillColor: Colors.black,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(height: 60),
const TextBoxWidget(
text: 'Please enter your recovery phrase'),
Center(
child: Form(
key: _formKey,
child: SizedBox(
width: 300,
child: GridView.count(
padding: const EdgeInsets.all(3),
crossAxisSpacing: 10,
mainAxisSpacing: 3,
shrinkWrap: true,
crossAxisCount: 3,
children: List.generate(12, (index) {
return SizedBox(
height: 50,
child: TextFormField(
controller: controllers[index],
decoration: InputDecoration(
filled: true,
fillColor: Colors.black,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
hintText: '${index + 1}',
),
hintText: '${index + 1}',
textInputAction: TextInputAction.next,
),
textInputAction: TextInputAction.next,
),
);
}),
)),
);
}),
)),
),
),
),
validationFailed
? const TextBoxWidget(text: 'Invalid keyphrase')
: const SizedBox(),
IntroButtonWidget(
text: 'Continue',
onPressed: () {
_onSubmit(context);
},
),
const SizedBox(height: 32),
],
validationFailed
? const TextBoxWidget(text: 'Invalid keyphrase')
: const SizedBox(),
IntroButtonWidget(
text: 'Continue',
onPressed: () {
_onSubmit(context);
},
),
const SizedBox(height: 32),
],
),
),
),
),
Expand All @@ -122,9 +125,18 @@ class _InputPhraseScreenState extends State<InputPhraseScreen> {

void _onSubmit(context) async {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
String wordsString = _words.join(' ');
// _formKey.currentState!.save();
// String wordsString = _words.join(' ');
String wordsString = '';

for (var controller in controllers) {
wordsString = '$wordsString${controller.text} ';
}

wordsString = wordsString.substring(0, wordsString.length - 1);

final t = bip39.validateMnemonic(wordsString);

if (t) {
// GoRouter.of(context).push("/passwordSetup/$wordsString");
showModalBottomSheet(
Expand Down
Loading

0 comments on commit d184e23

Please sign in to comment.