Skip to content

Commit

Permalink
Solved navigation bug from notification screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ge59dil committed Nov 23, 2023
1 parent f391caa commit 8e4cb93
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 113 deletions.
15 changes: 7 additions & 8 deletions lib/View/bookmarks_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ class BookmarksScreen extends ConsumerWidget {
case 0:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const CourseOverview()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
case 1:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const DownloadsScreen()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
case 2:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const BookmarksScreen()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
case 3:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => NotificationsScreen()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
default:
Expand Down Expand Up @@ -110,18 +110,17 @@ class BookmarksScreen extends ConsumerWidget {
],
),
);

}
}


class DownloadItem extends StatelessWidget {
final String imageName;
final String title;
final String date;
final String duration;

const DownloadItem({super.key,
const DownloadItem({
super.key,
required this.imageName,
required this.title,
required this.date,
Expand Down Expand Up @@ -164,4 +163,4 @@ class DownloadItem extends StatelessWidget {
),
);
}
}
}
26 changes: 13 additions & 13 deletions lib/View/courseoverview_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ class CourseOverview extends ConsumerWidget {
switch (index) {
case 0:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const CourseOverview()),
(Route<dynamic> route) => false,
MaterialPageRoute(builder: (context) => const CourseOverview()),
(Route<dynamic> route) => false,
);
break;
case 1:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const DownloadsScreen()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
case 2:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const BookmarksScreen()),
(Route<dynamic> route) => false,
MaterialPageRoute(builder: (context) => const BookmarksScreen()),
(Route<dynamic> route) => false,
);
break;
case 3:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => NotificationsScreen()),
(Route<dynamic> route) => false,
MaterialPageRoute(builder: (context) => NotificationsScreen()),
(Route<dynamic> route) => false,
);
break;
default:
Expand Down Expand Up @@ -82,9 +82,9 @@ class CourseOverview extends ConsumerWidget {
const Text(
'My Courses',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
IconButton(
Expand Down Expand Up @@ -127,9 +127,9 @@ class CourseOverview extends ConsumerWidget {
const Text(
'Public Courses',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
IconButton(
Expand Down
155 changes: 77 additions & 78 deletions lib/View/download_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,113 +15,112 @@ class DownloadsScreen extends ConsumerWidget {
case 0:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const CourseOverview()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
case 1:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const DownloadsScreen()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
case 2:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const BookmarksScreen()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
case 3:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => NotificationsScreen()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
break;
default:
break;
}
}

return Scaffold(
appBar: AppBar(
title: const Text('Downloads'),
actions: [
IconButton(
icon: const Icon(Icons.search),
onPressed: () {
// Implement search functionality
},
),
IconButton(
icon: const Icon(Icons.more_vert),
onPressed: () {
// Implement more options functionality
},
),
],
),
body: ListView(
children: const <Widget>[
DownloadItem(
imageName: 'assets/lecture_hall.jpg',
title: 'Lineare Algebra für Informatik [MA0901]',
date: 'July 24, 2019',
duration: '02:00:00',
),
DownloadItem(
imageName: 'assets/computer_science.jpg',
title: 'Computer Science [CS202]',
date: 'July 23, 2019',
duration: '02:00:00',
),
// Add more DownloadItem widgets as needed
],
),
bottomNavigationBar: BottomNavigationBar(
onTap: (index) => navigateToScreen(index, context),
items: const [
BottomNavigationBarItem(
icon: Icon(
Icons.home,
color: Colors.grey,
), // Replace with the exact color
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(
Icons.file_download,
color: Colors.blue,
), // 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',
),
],
),
);

}
return Scaffold(
appBar: AppBar(
title: const Text('Downloads'),
actions: [
IconButton(
icon: const Icon(Icons.search),
onPressed: () {
// Implement search functionality
},
),
IconButton(
icon: const Icon(Icons.more_vert),
onPressed: () {
// Implement more options functionality
},
),
],
),
body: ListView(
children: const <Widget>[
DownloadItem(
imageName: 'assets/lecture_hall.jpg',
title: 'Lineare Algebra für Informatik [MA0901]',
date: 'July 24, 2019',
duration: '02:00:00',
),
DownloadItem(
imageName: 'assets/computer_science.jpg',
title: 'Computer Science [CS202]',
date: 'July 23, 2019',
duration: '02:00:00',
),
// Add more DownloadItem widgets as needed
],
),
bottomNavigationBar: BottomNavigationBar(
onTap: (index) => navigateToScreen(index, context),
items: const [
BottomNavigationBarItem(
icon: Icon(
Icons.home,
color: Colors.grey,
), // Replace with the exact color
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(
Icons.file_download,
color: Colors.blue,
), // 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 DownloadItem extends StatelessWidget {
final String imageName;
final String title;
final String date;
final String duration;

const DownloadItem({super.key,
const DownloadItem({
super.key,
required this.imageName,
required this.title,
required this.date,
Expand Down Expand Up @@ -164,4 +163,4 @@ class DownloadItem extends StatelessWidget {
),
);
}
}
}
6 changes: 3 additions & 3 deletions lib/View/mycourses_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class MyCourses extends StatelessWidget {
Text(
'My Courses',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
],
Expand Down
19 changes: 11 additions & 8 deletions lib/View/notifications_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,27 @@ class NotificationsScreen extends ConsumerWidget {
switch (index) {
case 0:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const CourseOverview()),
(Route<dynamic> route) => false,
MaterialPageRoute(builder: (context) => const CourseOverview()),
(Route<dynamic> route) => false,
);
break;
case 1:
Navigator.push(context,
MaterialPageRoute(builder: (context) => const DownloadsScreen()),
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const DownloadsScreen()),
(Route<dynamic> route) => false,
);

break;
case 2:
Navigator.push(context,
MaterialPageRoute(builder: (context) => const BookmarksScreen()),
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const BookmarksScreen()),
(Route<dynamic> route) => false,
);
break;
case 3:
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => NotificationsScreen()),
(Route<dynamic> route) => false,
MaterialPageRoute(builder: (context) => NotificationsScreen()),
(Route<dynamic> route) => false,
);
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions lib/View/publiccourses_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class PublicCourses extends StatelessWidget {
Text(
'Public Courses',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
],
Expand Down

0 comments on commit 8e4cb93

Please sign in to comment.