Feat: add pages and navigation between them; random mass
This commit is contained in:
68
lib/pages/home.dart
Normal file
68
lib/pages/home.dart
Normal file
@ -0,0 +1,68 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fitneschi/pages/gain_room.dart';
|
||||
import 'package:fitneschi/pages/lose_room.dart';
|
||||
import 'dart:math';
|
||||
|
||||
int randomInRange(int min, int max) {
|
||||
final random = Random();
|
||||
return min + random.nextInt(max - min + 1);
|
||||
}
|
||||
|
||||
class Home extends StatefulWidget{
|
||||
const Home({super.key});
|
||||
|
||||
@override
|
||||
State<Home> createState() => _HomeState();
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home>{
|
||||
//vars
|
||||
int _mass = randomInRange(40, 80);
|
||||
//methods
|
||||
void _gainMass(){
|
||||
setState(() {
|
||||
_mass += randomInRange(1, 3);
|
||||
});
|
||||
}
|
||||
//ui
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: const Color.fromARGB(255, 38, 34, 46),
|
||||
title: const Text("Tamagochi 2.0"),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.scale),
|
||||
Text("Body Mass: "),
|
||||
Text(_mass.toString()),
|
||||
],
|
||||
),
|
||||
Text("Fat Pct"),
|
||||
Text("Daily Caloric Norm"),
|
||||
ElevatedButton(
|
||||
child: Text("Gain Mass"),
|
||||
onPressed: (){
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => GainRoom()),
|
||||
);
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text("Lose Mass"),
|
||||
onPressed: (){
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => LoseRoom()),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user