Skip to content

Commit

Permalink
feat: dashboard screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ravindranag committed Apr 17, 2023
1 parent 9115e48 commit 6e866e1
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -23,6 +24,15 @@ class _LoginFormState extends State<LoginForm> {

void _handleLogin() {
print({_emailController.text, _passwordController.text});
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) {
return const DashboardScreen();
},
),
(route) => false,
);
}

@override
Expand Down Expand Up @@ -138,5 +148,3 @@ class _LoginFormState extends State<LoginForm> {
);
}
}


41 changes: 41 additions & 0 deletions lib/src/features/dashboard/screen/dashboard/dashboard_screen.dart
Original file line number Diff line number Diff line change
@@ -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: <Widget>[
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),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -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,
),
],
),
],
)
],
),
],
),
),
),
),
);
}
}
Empty file.
19 changes: 19 additions & 0 deletions lib/src/widgets/common/FilledCard.dart
Original file line number Diff line number Diff line change
@@ -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,
);
}
}
24 changes: 24 additions & 0 deletions lib/src/widgets/common/OutlinedCard.dart
Original file line number Diff line number Diff line change
@@ -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,
);
}
}

0 comments on commit 6e866e1

Please sign in to comment.