Skip to content

Commit

Permalink
feat: generate random image colors in my dino
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lopez committed Oct 5, 2023
1 parent 3dc5a1f commit 8c7732c
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 21 deletions.
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/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 Down
1 change: 0 additions & 1 deletion lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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';
// import 'package:dinogrow/pages/coming_soon.dart';

class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter/material.dart';

import '../ui/widgets/widgets.dart';
import '../../ui/widgets/widgets.dart';

class ComingSoonScreen extends StatelessWidget {
final storage = const FlutterSecureStorage();
Expand All @@ -11,10 +11,14 @@ class ComingSoonScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Container(
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(color: Colors.transparent),
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/ui/intro_jungle_bg.png"),
fit: BoxFit.cover,
),
),
child: Padding(
padding: const EdgeInsets.all(12),
child: Center(
Expand All @@ -27,13 +31,11 @@ class ComingSoonScreen extends StatelessWidget {
const TextBoxWidget(text: 'Coming soon ^-^'),
const SizedBox(height: 30),
IntroButtonWidget(
text: 'Log out',
text: 'Return',
onPressed: () {
while (GoRouter.of(context).canPop() == true) {
GoRouter.of(context).pop();
}
GoRouter.of(context).pushReplacement("/");
GoRouter.of(context).pop();
},
size: 'fit',
),
]),
),
Expand Down
10 changes: 8 additions & 2 deletions lib/pages/mini-games/mini_games.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ class _MiniGamesPageState extends State<MiniGamesScreen> {
text: 'UP',
route: "/mini_games/up",
),
GameCardWidget(text: 'COMING SOON'),
GameCardWidget(text: 'COMING SOON'),
GameCardWidget(
text: 'COMING SOON',
route: "/mini_games/comming_soon",
),
GameCardWidget(
text: 'COMING SOON',
route: "/mini_games/comming_soon",
),
],
)),
),
Expand Down
71 changes: 61 additions & 10 deletions lib/pages/my-dinogrow/my_dinogrow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ class MydinogrowScreen extends StatefulWidget {

class _MydinogrowScreenState extends State<MydinogrowScreen> {
final storage = const FlutterSecureStorage();
final mintContent = (_onClaim) => [
final filters = [
Colors.white,
...List.generate(
Colors.primaries.length,
(index) => Colors.primaries[(index * 4) % Colors.primaries.length],
)
];

List<Widget> mintContent(_onClaim) => [
const IntroLogoWidget(),
const SizedBox(height: 30),
IntroButtonWidget(
Expand All @@ -32,14 +40,34 @@ class _MydinogrowScreenState extends State<MydinogrowScreen> {
)
];

final myDinosContent = [
const GameCardWidget(
text: 'Mini Dino',
route: "/mini_games/up",
),
const SizedBox(height: 30),
const TextBoxWidget(text: "Hi ^.^ I'm Mini Dino"),
];
List<Widget> myDinosContent(returnImageColorFc) => [
SizedBox(
height: 90,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: 12,
itemBuilder: (context, index) {
// final item = items[index];

return Container(
margin: const EdgeInsets.only(right: 12),
child: ClipRRect(
borderRadius: BorderRadius.circular(45),
child: returnImageColorFc(index),
),
);
},
),
),
const SizedBox(height: 30),
const GameCardWidget(
text: 'Mini Dino',
route: "/mini_games/up",
),
const SizedBox(height: 30),
const TextBoxWidget(text: "Hi ^.^ I'm Mini Dino"),
];

bool showDinos = false;

Expand All @@ -62,7 +90,9 @@ class _MydinogrowScreenState extends State<MydinogrowScreen> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
...(showDinos ? myDinosContent : mintContent(onClaim)),
...(showDinos
? myDinosContent(returnImageColor)
: mintContent(onClaim)),
const SizedBox(height: 30),
IntroButtonWidget(
text: 'Log out',
Expand All @@ -89,4 +119,25 @@ class _MydinogrowScreenState extends State<MydinogrowScreen> {
showDinos = true;
});
}

Image returnImageColor(int index) {
if (index == 0) {
return Image.asset(
'assets/images/logo.jpeg',
width: 90,
height: 90,
fit: BoxFit.cover,
colorBlendMode: BlendMode.color,
);
}

return Image.asset(
'assets/images/logo.jpeg',
width: 90,
height: 90,
fit: BoxFit.cover,
colorBlendMode: BlendMode.color,
color: filters[index],
);
}
}
3 changes: 3 additions & 0 deletions lib/pages/ranking/ranking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class RankingScreen extends StatelessWidget {
shrinkWrap: true,
itemCount: items.length,
itemBuilder: (context, index) {
items.sort((a, b) => double.parse(b.score)
.compareTo(double.parse(a.score)));

final item = items[index];

return ListTile(
Expand Down

0 comments on commit 8c7732c

Please sign in to comment.