diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8ae31bc..77b3d3a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,7 @@ + + { child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const SizedBox(height: 60), + const Expanded(child: SizedBox()), Container( color: Colors.orange[700], padding: const EdgeInsets.all(8), @@ -51,7 +51,9 @@ class _GeneratePhraseScreenState extends State { textAlign: TextAlign.center, ), ), + const Expanded(child: SizedBox()), TextBoxWidget(text: _mnemonic), + const Expanded(child: SizedBox()), IntroButtonWidget( text: 'Copy phrase', onPressed: () { @@ -63,6 +65,7 @@ class _GeneratePhraseScreenState extends State { ScaffoldMessenger.of(context).showSnackBar(snackBar); }, ), + const Expanded(child: SizedBox()), Container( decoration: const BoxDecoration(color: Colors.black), child: Row( @@ -76,9 +79,15 @@ class _GeneratePhraseScreenState extends State { }); }, ), - const Text("I have stored the recovery phrase securely"), + const Expanded( + child: Text( + "I have stored the recovery phrase securely", + textAlign: TextAlign.center, + ), + ), ], )), + const Expanded(child: SizedBox()), IntroButtonWidget( text: 'Continue', variant: _copied ? 'primary' : 'disabled', @@ -95,7 +104,6 @@ class _GeneratePhraseScreenState extends State { } : () {}, ), - const SizedBox(height: 60), ], ), ), diff --git a/lib/pages/home.dart b/lib/pages/home.dart index fc4456a..b542ae8 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -29,16 +29,18 @@ class _HomeScreenState extends State { @override Widget build(BuildContext context) { + final statusBarHeight = MediaQuery.of(context).viewPadding.top; + return DefaultTabController( length: 4, child: Scaffold( appBar: AppBar( backgroundColor: const Color.fromRGBO(241, 189, 57, 1), elevation: 6, - toolbarHeight: 120, + toolbarHeight: 122 + (statusBarHeight > 0 ? 41 : 0) - statusBarHeight, flexibleSpace: Column( children: [ - const SizedBox(height: 38), + SizedBox(height: statusBarHeight), Card( color: Colors.white, shadowColor: Colors.white, @@ -58,6 +60,7 @@ class _HomeScreenState extends State { _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), @@ -71,6 +74,7 @@ class _HomeScreenState extends State { _balance != null ? double.parse(_balance ?? '0').toStringAsFixed(2) : 'Loading...', + maxLines: 1, style: const TextStyle(color: Colors.black)), const SizedBox(width: 3), const Text('SOL', @@ -119,7 +123,7 @@ class _HomeScreenState extends State { physics: const NeverScrollableScrollPhysics(), children: [ const MiniGamesScreen(), - RankingScreen(), + const RankingScreen(), MydinogrowScreen( address: _publicKey ?? '', getBalance: () => _getBalance()), WalletScreen( diff --git a/lib/pages/input_phrase.dart b/lib/pages/input_phrase.dart index d44cd0f..04d8d5d 100644 --- a/lib/pages/input_phrase.dart +++ b/lib/pages/input_phrase.dart @@ -13,7 +13,6 @@ class InputPhraseScreen extends StatefulWidget { class _InputPhraseScreenState extends State { final _formKey = GlobalKey(); - bool validationFailed = false; var controllers = List.generate(12, (i) => TextEditingController()); @@ -70,50 +69,46 @@ class _InputPhraseScreenState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const SizedBox(height: 60), + const Expanded(child: SizedBox()), const TextBoxWidget( text: 'Please enter your recovery phrase'), + const Expanded(child: SizedBox()), 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}', - ), - textInputAction: TextInputAction.next, + 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}', + ), + textInputAction: TextInputAction.next, + ), + ); + }), + )), ), ), - validationFailed - ? const TextBoxWidget(text: 'Invalid keyphrase') - : const SizedBox(), IntroButtonWidget( text: 'Continue', onPressed: () { _onSubmit(context); }, ), - const SizedBox(height: 32), ], ), ), @@ -147,9 +142,15 @@ class _InputPhraseScreenState extends State { }, ); } else { - setState(() { - validationFailed = true; - }); + const snackBar = SnackBar( + content: Text( + 'Error: Invalid keyphrase', + style: TextStyle(color: Colors.white), + ), + backgroundColor: Colors.red, + ); + + ScaffoldMessenger.of(context).showSnackBar(snackBar); } } } diff --git a/lib/pages/login.dart b/lib/pages/login.dart index 5c06a10..480d722 100644 --- a/lib/pages/login.dart +++ b/lib/pages/login.dart @@ -57,13 +57,13 @@ class _LoginScreenState extends State { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - const SizedBox(height: 60), + const Expanded(child: SizedBox()), const IntroLogoWidget(), - const SizedBox(height: 30), + const Expanded(child: SizedBox()), const TextBoxWidget( text: 'To continue, please enter your current password'), - const SizedBox(height: 16), + const Expanded(child: SizedBox()), Form( key: _formKey, child: Column( @@ -81,13 +81,12 @@ class _LoginScreenState extends State { ), ), ), - const SizedBox(height: 8), - const SizedBox(height: 8), + const SizedBox(height: 12), IntroButtonWidget( text: 'Login', onPressed: _onSubmit, ), - const SizedBox(height: 32), + const SizedBox(height: 12), IntroButtonWidget( text: 'Use different Account', onPressed: () { @@ -97,7 +96,7 @@ class _LoginScreenState extends State { ], ), ), - const SizedBox(height: 60), + const Expanded(child: SizedBox()), ]), ), ), diff --git a/lib/pages/mini-games/up/down.dart b/lib/pages/mini-games/up/down.dart index 1821cb2..524a381 100644 --- a/lib/pages/mini-games/up/down.dart +++ b/lib/pages/mini-games/up/down.dart @@ -135,9 +135,8 @@ class DownGame extends Forge2DGame with TapDetector { @override Future onLoad() async { final screenSize = Vector2(size.x, size.y); - // Scaled viewport size - final worldSize = Vector2(7.2, 12.8); + final worldSize = screenSize; await super.onLoad(); @@ -157,9 +156,9 @@ class DownGame extends Forge2DGame with TapDetector { // windowSize: 60, // textRenderer: TextPaint(style: const TextStyle(color: Colors.white)))); - add(Floor()); - add(LeftWall()); - add(RightWall()); + add(Floor(worldSize)); + add(LeftWall(worldSize)); + add(RightWall(worldSize)); //Testing // Add instance of Box @@ -168,36 +167,41 @@ class DownGame extends Forge2DGame with TapDetector { endGameCallback('$score'); } - newBoxAndScore() { + newBoxAndScore() async { score += 1; scoreText.text = 'Score: ${score.toString().padLeft(3, '0')}'; - add(Box(newBoxAndScore, finishGame)); + + await Future.delayed(const Duration(milliseconds: 1000), () { + add(Box(newBoxAndScore, finishGame, worldSize)); + }); } - add(Box(newBoxAndScore, finishGame)); + await Future.delayed(const Duration(milliseconds: 1000), () { + add(Box(newBoxAndScore, finishGame, worldSize)); + }); // Render floor final boxFloor1 = BoxFloor() ..x = 1 - ..y = worldSize.y - 5.7; + ..y = worldSize.y - 1; await boxFloor1.loadImage(); add(boxFloor1); final boxFloor2 = BoxFloor() ..x = 2 - ..y = worldSize.y - 5.7; + ..y = worldSize.y - 1; await boxFloor2.loadImage(); add(boxFloor2); final leftFloor = LeftFloor() ..x = 0 - ..y = worldSize.y - 5.7; + ..y = worldSize.y - 1; await leftFloor.loadImage(); add(leftFloor); final rightFloor = RightFloor() ..x = 3 - ..y = worldSize.y - 5.7; + ..y = worldSize.y - 1; await rightFloor.loadImage(); add(rightFloor); @@ -205,12 +209,14 @@ class DownGame extends Forge2DGame with TapDetector { add(dino); // add the buttons to the game + btnLeft.position = Vector2(0, worldSize.y - 1); + btnRight.position = Vector2(3, worldSize.y - 1); add(btnLeft); add(btnRight); // add(btnJump); // add(btnAttack); - add(btnJumpText); - add(btnAttackText); + // add(btnJumpText); + // add(btnAttackText); // Score text final btnStyleLetters = TextPaint( diff --git a/lib/pages/mini-games/up/objects/box.dart b/lib/pages/mini-games/up/objects/box.dart index 7385177..cbdd283 100644 --- a/lib/pages/mini-games/up/objects/box.dart +++ b/lib/pages/mini-games/up/objects/box.dart @@ -1,6 +1,5 @@ import 'dart:math'; -import 'package:dinogrow/pages/mini-games/up/objects/floor.dart'; import 'package:flame/components.dart'; import 'package:flame_forge2d/flame_forge2d.dart'; @@ -9,8 +8,10 @@ import 'dino.dart'; class Box extends BodyComponent with ContactCallbacks { final Function onCollisionBox; final Function onCollisionDino; + final Vector2 worldSize; - Box(this.onCollisionBox, this.onCollisionDino) : super(priority: 1); + Box(this.onCollisionBox, this.onCollisionDino, this.worldSize) + : super(priority: 1); @override Future onLoad() async { @@ -28,21 +29,21 @@ class Box extends BodyComponent with ContactCallbacks { @override void beginContact(Object other, Contact contact) { removeFromParent(); - if (other is Floor) { - onCollisionBox(); - } else if (other is Dino) { + if (other is Dino) { onCollisionDino(); } + onCollisionBox(); } @override Body createBody() { final rnd = Random(); - + final xpos = (rnd.nextDouble() * (worldSize.x - 1)).abs(); + print('xpos: ${xpos}'); final bodyDef = BodyDef( userData: this, //position: Vector2(worldSize.x / 2, worldSize.y - 3), change dino position later - position: Vector2(rnd.nextDouble() * 2.8 + 0.2, -1), + position: Vector2(xpos, -1), type: BodyType.dynamic, gravityOverride: Vector2(0, rnd.nextDouble() * 3 + 2), ); diff --git a/lib/pages/mini-games/up/objects/floor.dart b/lib/pages/mini-games/up/objects/floor.dart index 821f62a..b56777c 100644 --- a/lib/pages/mini-games/up/objects/floor.dart +++ b/lib/pages/mini-games/up/objects/floor.dart @@ -1,12 +1,14 @@ import 'package:flame_forge2d/flame_forge2d.dart'; -import 'package:dinogrow/pages/mini-games/up/up.dart'; class Floor extends BodyComponent { + final Vector2 worldSize; + Floor(this.worldSize); + @override Body createBody() { final bodyDef = BodyDef( userData: this, - position: Vector2(0, worldSize.y - 5.7), + position: Vector2(0, worldSize.y - 1), type: BodyType.static, ); @@ -19,10 +21,13 @@ class Floor extends BodyComponent { } class LeftWall extends BodyComponent { + final Vector2 worldSize; + LeftWall(this.worldSize); + @override Body createBody() { final bodyDef = BodyDef( - position: Vector2(-0.3, 0), + position: Vector2(0, 0), type: BodyType.static, ); @@ -35,10 +40,13 @@ class LeftWall extends BodyComponent { } class RightWall extends BodyComponent { + final Vector2 worldSize; + RightWall(this.worldSize); + @override Body createBody() { final bodyDef = BodyDef( - position: Vector2(worldSize.x - 3, 0), + position: Vector2(worldSize.x, 0), type: BodyType.static, ); diff --git a/lib/pages/mini-games/up/up.dart b/lib/pages/mini-games/up/up.dart index 45e7c95..62116ea 100644 --- a/lib/pages/mini-games/up/up.dart +++ b/lib/pages/mini-games/up/up.dart @@ -123,7 +123,7 @@ class UpGame extends Forge2DGame with TapDetector { windowSize: 60, textRenderer: TextPaint(style: const TextStyle(color: Colors.white)))); - add(Floor()); + add(Floor(worldSize)); //Testing // Add instance of Box diff --git a/lib/pages/setup_account.dart b/lib/pages/setup_account.dart index 40c0bbb..0947eef 100644 --- a/lib/pages/setup_account.dart +++ b/lib/pages/setup_account.dart @@ -24,8 +24,9 @@ class SetUpScreen extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ + const Expanded(child: SizedBox()), const IntroLogoWidget(), - const SizedBox(height: 120), + const Expanded(child: SizedBox()), IntroButtonWidget( text: 'I have a recovery Phrase', onPressed: () => context.push('/inputphrase'), @@ -35,6 +36,7 @@ class SetUpScreen extends StatelessWidget { text: 'Generate new wallet', onPressed: () => context.push('/generatePhrase'), ), + const Expanded(child: SizedBox()), ], ), ), diff --git a/lib/ui/widgets/IntroButton/intro_button.dart b/lib/ui/widgets/IntroButton/intro_button.dart index fc462b9..e55abf7 100644 --- a/lib/ui/widgets/IntroButton/intro_button.dart +++ b/lib/ui/widgets/IntroButton/intro_button.dart @@ -40,6 +40,7 @@ class IntroButtonWidget extends StatelessWidget { color: Color.fromRGBO(34, 38, 59, 1), fontWeight: FontWeight.bold, fontSize: 24), + textAlign: TextAlign.center, ), ); } diff --git a/lib/ui/widgets/IntroLogo/intro_logo.dart b/lib/ui/widgets/IntroLogo/intro_logo.dart index 422aec8..00f5545 100644 --- a/lib/ui/widgets/IntroLogo/intro_logo.dart +++ b/lib/ui/widgets/IntroLogo/intro_logo.dart @@ -42,6 +42,8 @@ class _IntroLogoWidgetState extends State @override Widget build(BuildContext context) { + double widthLogo = MediaQuery.of(context).size.width * .5; + return AnimatedBuilder( animation: controller, builder: (context, child) => Transform.rotate( @@ -57,13 +59,13 @@ class _IntroLogoWidgetState extends State blurRadius: 6, ), ], - borderRadius: BorderRadius.circular(120), + borderRadius: BorderRadius.circular(widthLogo / 2), ), child: ClipRRect( - borderRadius: BorderRadius.circular(120), + borderRadius: BorderRadius.circular(widthLogo / 2), child: Image.asset( 'assets/images/logo.jpeg', - width: 210, + width: widthLogo, ), ), ), diff --git a/lib/ui/widgets/TextBox/text_box.dart b/lib/ui/widgets/TextBox/text_box.dart index 131f982..1e7ec6e 100644 --- a/lib/ui/widgets/TextBox/text_box.dart +++ b/lib/ui/widgets/TextBox/text_box.dart @@ -11,7 +11,7 @@ class TextBoxWidget extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - padding: const EdgeInsets.all(24), + padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(24),