Skip to content

Commit

Permalink
v1.0.3+5
Browse files Browse the repository at this point in the history
  • Loading branch information
biplobsd committed Mar 29, 2022
1 parent 09ec4ef commit 3eb1f8a
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 140 deletions.
119 changes: 75 additions & 44 deletions lib/app/view/course_enrolment/course_enrolment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,27 @@ class CourseEnrolmentPage extends StatelessWidget {
}
}

class CourseEnrolmentScreen extends StatelessWidget {
class CourseEnrolmentScreen extends StatefulWidget {
CourseEnrolmentScreen({
Key? key,
}) : super(key: key);

List<Course>? listCourses;
@override
State<CourseEnrolmentScreen> createState() => _CourseEnrolmentScreenState();
}

class _CourseEnrolmentScreenState extends State<CourseEnrolmentScreen> {
List<Course> listCourses = [
Course(
title: 'Algorithms[PC-A+PC-B][Spring-22]',
id: 14226,
enrollmentKey: 'CSE1234',
)
];

TextEditingController urlController = TextEditingController();

TextEditingController enrollkeyController = TextEditingController();

@override
Widget build(BuildContext context) {
Expand All @@ -31,57 +46,73 @@ class CourseEnrolmentScreen extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (listCourses != null)
...listCourses!.map(
(e) => ListTile(
leading: IconButton(
icon: const Icon(Icons.tiktok),
onPressed: () {},
),
title: Text(e.title),
trailing: IconButton(
icon: const Icon(Icons.delete),
onPressed: () {},
),
...listCourses.map(
(e) => ListTile(
leading: IconButton(
icon: const Icon(Icons.tiktok),
onPressed: () {},
),
title: Text(e.title),
trailing: IconButton(
icon: const Icon(Icons.delete),
onPressed: () {
setState(() {
listCourses.removeWhere((element) => element.id == e.id);
});
},
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25),
child: ElevatedButton(
onPressed: () {
showDialog<dynamic>(
context: context,
builder: (ctx) => AlertDialog(
title: const Text('Add your course'),
content: Container(
height: 150,
child: Column(
children: const [
TextField(
decoration: InputDecoration(
label: Text('URL'),
),
),
SizedBox(
height: 10,
),
TextField(
decoration: InputDecoration(
label: Text('Enroll key'),
),
),
],
context: context,
builder: (ctx) => AlertDialog(
title: const Text('Add your course'),
content: Container(
height: 150,
child: Column(
children: [
TextField(
controller: urlController,
decoration: const InputDecoration(
label: Text('URL'),
),
),
actions: [
TextButton(
child: const Text('Add'),
onPressed: () {
Navigator.pop(context);
},
)
],
));
const SizedBox(
height: 10,
),
TextField(
controller: enrollkeyController,
decoration: const InputDecoration(
label: Text('Enroll key'),
),
),
],
),
),
actions: [
TextButton(
child: const Text('Add'),
onPressed: () {
setState(() {
listCourses.add(
Course(
id: 111,
title: urlController.text,
enrollmentKey: enrollkeyController.text,
),
);
});

Navigator.pop(context);
},
)
],
),
);
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.black12),
Expand Down
3 changes: 2 additions & 1 deletion lib/app/view/course_enrolment/models/course.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ class Course {
Course({
required this.title,
required this.enrollmentKey,
required this.id,
});

int id;
String title;
String enrollmentKey;
}
200 changes: 111 additions & 89 deletions lib/app/view/menus_page/menus_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,101 +12,24 @@ class MenuesPage extends StatelessWidget {
const MenuesPage({Key? key}) : super(key: key);
static const pathName = '/menus';

@override
Widget build(BuildContext context) {
return MenueScreen();
}
}

class MenueScreen extends StatelessWidget {
const MenueScreen({
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: const MyAppbar(
title: Text('DIUSpeeder'),
),
body: ListView.builder(
itemCount: menus.length,
padding: const EdgeInsets.only(top: 10, left: 20, right: 20),
itemBuilder: (ctx, index) => Stack(
children: [
Container(
height: 140,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.blueGrey.withOpacity(0.1),
BlendMode.dstATop,
),
image: menus[index].image,
),
borderRadius: BorderRadius.circular(15),
gradient: menus[index].gradient,
),
margin: const EdgeInsets.only(bottom: 15),
child: InkWell(
onTap: () {
if (!menus[index].isComingSoon) {
if (menus[index].isLoginRequired) {
if (BlocProvider.of<AuthblcCubit>(context).state
is AuthblcLoginState) {
Navigator.of(context).pushNamed(menus[index].pageOpen);
} else {
Navigator.of(context).pushNamed(
LoginPage.pathName,
arguments: menus[index].pageOpen,
);
}
} else {
Navigator.of(context).pushNamed(menus[index].pageOpen);
}
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'This option is coming soon 🥺. Stay with us. ',
),
),
);
}
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
menus[index].icon,
size: 50,
color: menus[index].titleIconColor,
),
const SizedBox(
height: 5,
),
Text(
menus[index].title,
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: menus[index].titleIconColor.withOpacity(0.8),
fontWeight: FontWeight.bold,
),
),
],
),
),
),
if (menus[index].isComingSoon)
Container(
height: 140,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.black38,
borderRadius: BorderRadius.circular(15),
),
child: Center(
child: FittedBox(
child: Text(
'Coming soon',
style: Theme.of(context).textTheme.headline4,
),
),
),
),
],
),
),
body: const MenuItemWidgets(),
bottomNavigationBar: Container(
decoration: BoxDecoration(
border: Border.all(width: 0.7, color: Colors.white10),
Expand Down Expand Up @@ -157,3 +80,102 @@ class MenuesPage extends StatelessWidget {
);
}
}

class MenuItemWidgets extends StatelessWidget {
const MenuItemWidgets({
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: menus.length,
padding: const EdgeInsets.only(top: 10, left: 20, right: 20),
itemBuilder: (ctx, index) => Stack(
children: [
Container(
height: 140,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.blueGrey.withOpacity(0.1),
BlendMode.dstATop,
),
image: menus[index].image,
),
borderRadius: BorderRadius.circular(15),
gradient: menus[index].gradient,
),
margin: const EdgeInsets.only(bottom: 15),
child: InkWell(
onTap: () {
if (!menus[index].isComingSoon) {
if (menus[index].isLoginRequired) {
if (BlocProvider.of<AuthblcCubit>(context).state
is AuthblcLoginState) {
Navigator.of(context).pushNamed(menus[index].pageOpen);
} else {
Navigator.of(context).pushNamed(
LoginPage.pathName,
arguments: menus[index].pageOpen,
);
}
} else {
Navigator.of(context).pushNamed(menus[index].pageOpen);
}
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'This option is coming soon 🥺. Stay with us. ',
),
),
);
}
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
menus[index].icon,
size: 50,
color: menus[index].titleIconColor,
),
const SizedBox(
height: 5,
),
Text(
menus[index].title,
style: Theme.of(context).textTheme.titleLarge!.copyWith(
color: menus[index].titleIconColor.withOpacity(0.8),
fontWeight: FontWeight.bold,
),
),
],
),
),
),
if (menus[index].isComingSoon)
Container(
height: 140,
width: double.infinity,
decoration: BoxDecoration(
color: Colors.black38,
borderRadius: BorderRadius.circular(15),
),
child: Center(
child: FittedBox(
child: Text(
'Coming soon',
style: Theme.of(context).textTheme.headline4,
),
),
),
),
],
),
);
}
}
2 changes: 1 addition & 1 deletion lib/app/view/menus_page/model/menus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const List<Menu> menus = [
icon: Icons.join_full_outlined,
title: 'Course enrolment',
titleIconColor: Colors.white,
isComingSoon: false,
isComingSoon: true,
),
Menu(
image: AssetImage('assets/sgpaBar.png'),
Expand Down
2 changes: 1 addition & 1 deletion lib/core/themes/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AppTheme {
);

static Brightness get currentSystemBrightness =>
SchedulerBinding.instance!.window.platformBrightness;
SchedulerBinding.instance.window.platformBrightness;

static void setStatusBarAndNavigationBarColors(ThemeMode themeMode) {
SystemChrome.setSystemUIOverlayStyle(
Expand Down
Loading

0 comments on commit 3eb1f8a

Please sign in to comment.