| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import 'package:flutter/material.dart';
- import 'package:physigo/Services/AuthService.dart';
- import 'package:physigo/challenge/daily_challenge_page.dart';
- import 'package:physigo/challenge/weekly_challenge_page.dart';
- class HomePage extends StatelessWidget {
- const HomePage({Key? key}) : super(key: key);
- String get name => AuthenticationServices.user!.name;
- num get totalPoint => AuthenticationServices.user!.totalPoints;
- @override
- Widget build(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.all(16.0),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(
- "Welcome back $name!",
- textAlign: TextAlign.center,
- style: const TextStyle(
- fontSize: 28,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 36),
- Column(
- children: const [
- Align(
- alignment: Alignment.bottomLeft,
- child: Text(
- "Here are your challenges:",
- style: TextStyle(fontSize: 24),
- ),
- ),
- SizedBox(height: 24),
- ChallengeTile(
- challengeType: "Daily",
- challengePage: DailyChallengePage(),
- ),
- ChallengeTile(
- challengeType: "Weekly",
- challengePage: WeeklyChallengePage(),
- ),
- ],
- ),
- ],
- ),
- );
- }
- }
- class ChallengeTile extends StatelessWidget {
- final Widget challengePage;
- const ChallengeTile({
- required this.challengePage,
- required this.challengeType,
- Key? key,
- }) : super(key: key);
- final String challengeType;
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- width: MediaQuery.of(context).size.width * 0.6,
- child: Card(
- elevation: 3,
- color: Colors.blueGrey,
- child: ListTile(
- title: Text(
- challengeType.toUpperCase(),
- textAlign: TextAlign.center,
- style: const TextStyle(
- fontSize: 18,
- fontWeight: FontWeight.bold,
- letterSpacing: 1.8,
- color: Colors.white,
- ),
- ),
- trailing: const Icon(Icons.arrow_forward, color: Colors.white),
- onTap: () {
- Navigator.push(context, MaterialPageRoute(builder: (_) => challengePage));
- },
- ),
- ),
- );
- }
- }
|