Skip to content

Commit

Permalink
Added mycourses and public courses views,also solved navigation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ge59dil committed Nov 21, 2023
1 parent 8bdffa4 commit e0c2224
Show file tree
Hide file tree
Showing 4 changed files with 329 additions and 23 deletions.
62 changes: 44 additions & 18 deletions lib/View/courseoverview_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:gocast_mobile/View/mycourses_screen.dart';
import 'package:gocast_mobile/View/publiccourses_screen.dart';
import 'settings_screen.dart';

class CourseOverview extends StatelessWidget {
Expand Down Expand Up @@ -34,15 +36,27 @@ class CourseOverview extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.all(16.0),
child: Text(
'My Courses',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
), // Replace with the exact color
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'My Courses',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black),
),
IconButton(
icon: const Icon(Icons.arrow_forward),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const MyCourses(),
),
);
},
),
],
),
),
// Horizontal list view for My Courses
Expand All @@ -62,15 +76,27 @@ class CourseOverview extends StatelessWidget {
],
),
),
const Padding(
padding: EdgeInsets.all(16.0),
child: Text(
'Public Courses',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
), // Replace with the exact color
Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Public Courses',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black),
),
IconButton(
icon: const Icon(Icons.arrow_forward),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const PublicCourses(),
),
);
},
),
],
),
),
// Horizontal list view for Public Courses
Expand Down
141 changes: 141 additions & 0 deletions lib/View/mycourses_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import 'package:flutter/material.dart';
import 'settings_screen.dart';

class MyCourses extends StatelessWidget {
const MyCourses({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white, // Replace with the exact color
title: const Text('GoCast',
style:
TextStyle(color: Colors.black),
), // Replace with the exact color
actions: [
IconButton(
icon: const Icon(Icons.settings,
color: Colors.black,
), // Replace with the exact color
onPressed: () {
// Settings action
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SettingsScreen(),
),
);
},
),
],
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [

const Padding(
padding: EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'My Courses',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black),
),
],
),
),
// Horizontal list view for My Courses
SizedBox(
height: 200, // Adjust the height as needed
child: ListView(
scrollDirection: Axis.horizontal,
children: const [
CourseCard(
title: 'PSY101', subtitle: 'Introduction to Psychology',
),
CourseCard(
title: 'CS202',
subtitle: 'Introduction to Computer Science',
),
// Add more courses as needed
],
),
),
],
),
),
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home,
color: Colors.blue,
), // Replace with the exact color
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.download,
color: Colors.grey,
), // Replace with the exact color
label: 'Downloads',
),
BottomNavigationBarItem(
icon: Icon(Icons.bookmark,
color: Colors.grey,
), // Replace with the exact color
label: 'Bookmarks',
),
BottomNavigationBarItem(
icon: Icon(Icons.notifications,
color: Colors.grey,
), // Replace with the exact color
label: 'Notifications',
),
],
),
);
}
}

class CourseCard extends StatelessWidget {
final String title;
final String subtitle;

const CourseCard({super.key, required this.title, required this.subtitle});

@override
Widget build(BuildContext context) {
return Container(
width: 160, // Adjust the width as needed
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Image.asset(
'path_to_your_course_image', // Replace with the actual path to your course image
fit: BoxFit.cover,
),
),
Text(
title,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
), // Replace with the exact color
),
Text(
subtitle,
style: const TextStyle(
fontSize: 16,
color: Colors.grey,
), // Replace with the exact color
),
],
),
);
}
}
141 changes: 141 additions & 0 deletions lib/View/publiccourses_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import 'package:flutter/material.dart';
import 'settings_screen.dart';

class PublicCourses extends StatelessWidget {
const PublicCourses({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white, // Replace with the exact color
title: const Text('GoCast',
style:
TextStyle(color: Colors.black),
), // Replace with the exact color
actions: [
IconButton(
icon: const Icon(Icons.settings,
color: Colors.black,
), // Replace with the exact color
onPressed: () {
// Settings action
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const SettingsScreen(),
),
);
},
),
],
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [

const Padding(
padding: EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Public Courses',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.black),
),

],
),
),
// Horizontal list view for Public Courses
SizedBox(
height: 200, // Adjust the height as needed
child: ListView(
scrollDirection: Axis.horizontal,
children: const [
CourseCard(
title: 'PSY101', subtitle: 'Public Psychology Course',
),
CourseCard(
title: 'PSY101', subtitle: 'Public Psychology Course',
),
// Add more courses as needed
],
),
),
],
),
),
bottomNavigationBar: BottomNavigationBar(
items: const [
BottomNavigationBarItem(
icon: Icon(Icons.home,
color: Colors.blue,
), // Replace with the exact color
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.download,
color: Colors.grey,
), // Replace with the exact color
label: 'Downloads',
),
BottomNavigationBarItem(
icon: Icon(Icons.bookmark,
color: Colors.grey,
), // Replace with the exact color
label: 'Bookmarks',
),
BottomNavigationBarItem(
icon: Icon(Icons.notifications,
color: Colors.grey,
), // Replace with the exact color
label: 'Notifications',
),
],
),
);
}
}

class CourseCard extends StatelessWidget {
final String title;
final String subtitle;

const CourseCard({super.key, required this.title, required this.subtitle});

@override
Widget build(BuildContext context) {
return Container(
width: 160, // Adjust the width as needed
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Image.asset(
'path_to_your_course_image', // Replace with the actual path to your course image
fit: BoxFit.cover,
),
),
Text(
title,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black,
), // Replace with the exact color
),
Text(
subtitle,
style: const TextStyle(
fontSize: 16,
color: Colors.grey,
), // Replace with the exact color
),
],
),
);
}
}
8 changes: 3 additions & 5 deletions lib/View/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
onTap: () {
// Handle log out
ref.read(userViewModel).logout();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Loginscreen(),
),
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const Loginscreen()),
(Route<dynamic> route) => false,
);
},
),
Expand Down

0 comments on commit e0c2224

Please sign in to comment.