diff --git a/lib/src/features/authentication/screen/login/widgets/LoginForm.dart b/lib/src/features/authentication/screen/login/widgets/LoginForm.dart index 174651f..784df27 100644 --- a/lib/src/features/authentication/screen/login/widgets/LoginForm.dart +++ b/lib/src/features/authentication/screen/login/widgets/LoginForm.dart @@ -1,6 +1,7 @@ import 'package:courses_app/src/constants/images.dart'; import 'package:courses_app/src/constants/text.dart'; import 'package:courses_app/src/features/authentication/screen/signup/signup_screen.dart'; +import 'package:courses_app/src/features/dashboard/screen/dashboard/dashboard_screen.dart'; import 'package:courses_app/src/widgets/common/outlined_password_text_field.dart'; import 'package:courses_app/src/widgets/common/outlined_text_field.dart'; import 'package:flutter/material.dart'; @@ -23,6 +24,15 @@ class _LoginFormState extends State { void _handleLogin() { print({_emailController.text, _passwordController.text}); + Navigator.pushAndRemoveUntil( + context, + MaterialPageRoute( + builder: (context) { + return const DashboardScreen(); + }, + ), + (route) => false, + ); } @override @@ -138,5 +148,3 @@ class _LoginFormState extends State { ); } } - - diff --git a/lib/src/features/dashboard/screen/dashboard/dashboard_screen.dart b/lib/src/features/dashboard/screen/dashboard/dashboard_screen.dart new file mode 100644 index 0000000..3e3ab26 --- /dev/null +++ b/lib/src/features/dashboard/screen/dashboard/dashboard_screen.dart @@ -0,0 +1,41 @@ +import 'package:courses_app/src/widgets/common/FilledCard.dart'; +import 'package:courses_app/src/widgets/common/OutlinedCard.dart'; +import 'package:flutter/material.dart'; + +import 'widgets/subject_card.dart'; + +class DashboardScreen extends StatelessWidget { + const DashboardScreen({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Hi Ravindra'), + ), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: CustomScrollView( + slivers: [ + SliverList( + delegate: SliverChildBuilderDelegate((context, index) { + return SubjectCard( + subjectName: 'Subject $index', + attended: 20, + classes: 30, + onTap: () { + print('open card $index'); + }, + ); + }, childCount: 8), + ) + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: () {}, + child: const Icon(Icons.add), + ), + ); + } +} diff --git a/lib/src/features/dashboard/screen/dashboard/widgets/subject_card.dart b/lib/src/features/dashboard/screen/dashboard/widgets/subject_card.dart new file mode 100644 index 0000000..860f93f --- /dev/null +++ b/lib/src/features/dashboard/screen/dashboard/widgets/subject_card.dart @@ -0,0 +1,99 @@ +import 'package:courses_app/src/widgets/common/OutlinedCard.dart'; +import 'package:flutter/material.dart'; + +class SubjectCard extends StatelessWidget { + SubjectCard({ + super.key, + required this.subjectName, + required this.attended, + required this.classes, + this.onTap + }); + + String subjectName; + int classes; + int attended; + Function? onTap; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(vertical: 10.0), + child: OutlinedCard( + child: InkWell( + onTap: () => onTap!(), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + subjectName, + style: Theme.of(context).textTheme.titleLarge?.apply( + color: Theme.of(context).colorScheme.primary), + ), + ), + IconButton( + onPressed: () {}, + icon: const Icon(Icons.arrow_forward), + ) + ], + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0), + child: Divider( + color: Theme.of(context).colorScheme.onSecondaryContainer, + ), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + '${(attended / classes * 100).toStringAsFixed(1).toString()}%', + style: Theme.of(context).textTheme.displayMedium?.apply( + color: Theme.of(context).colorScheme.tertiary), + ), + ), + Row( + children: [ + SizedBox( + width: 16.0, + height: 16.0, + child: CircularProgressIndicator( + value: 0.60, + color: Theme.of(context).colorScheme.tertiary, + strokeWidth: 3.0, + ), + ), + const SizedBox( + width: 10.0, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + '${classes.toString()} classes', + style: Theme.of(context).textTheme.bodySmall, + ), + Text( + '${attended.toString()} attended', + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ), + ], + ) + ], + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/src/features/dashboard/screen/dashboard_screen.dart b/lib/src/features/dashboard/screen/dashboard_screen.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/src/widgets/common/FilledCard.dart b/lib/src/widgets/common/FilledCard.dart new file mode 100644 index 0000000..2d1d7c1 --- /dev/null +++ b/lib/src/widgets/common/FilledCard.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class FilledCard extends StatelessWidget { + FilledCard({ + Key? key, + required this.child, + }) : super(key: key); + + Widget child; + + @override + Widget build(BuildContext context) { + return Card( + elevation: 0, + color: Theme.of(context).colorScheme.surfaceVariant, + child: child, + ); + } +} diff --git a/lib/src/widgets/common/OutlinedCard.dart b/lib/src/widgets/common/OutlinedCard.dart new file mode 100644 index 0000000..13f26a9 --- /dev/null +++ b/lib/src/widgets/common/OutlinedCard.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; + +class OutlinedCard extends StatelessWidget { + OutlinedCard({ + Key? key, + required this.child, + }) : super(key: key); + + Widget child; + + @override + Widget build(BuildContext context) { + return Card( + elevation: 0, + shape: RoundedRectangleBorder( + side: BorderSide( + color: Theme.of(context).colorScheme.outline + ), + borderRadius: const BorderRadius.all(Radius.circular(12)) + ), + child: child, + ); + } +}