Skip to content

Commit

Permalink
Merge pull request #123 from CosmicRaptor/main
Browse files Browse the repository at this point in the history
Added a new common appbar for all screens opened via the drawer.
  • Loading branch information
CosmicRaptor authored Jun 13, 2024
2 parents 0360e33 + 677f130 commit 3bb8780
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 43 deletions.
2 changes: 2 additions & 0 deletions lib/new_ui/screens/committees_screen/committees_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter/services.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
import 'package:tsec_app/models/committee_model/committee_model.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:tsec_app/new_ui/screens/main_screen/widgets/common_basic_appbar.dart';

class CommitteesScreen extends StatefulWidget {
const CommitteesScreen({Key? key}) : super(key: key);
Expand Down Expand Up @@ -40,6 +41,7 @@ class _CommitteesScreenState extends State<CommitteesScreen> {
double _height = MediaQuery.of(context).size.height;
double _width = MediaQuery.of(context).size.width;
return Scaffold(
appBar: CommonAppbar(),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
Expand Down
10 changes: 4 additions & 6 deletions lib/new_ui/screens/main_screen/main_screen.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
import 'dart:io';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:tsec_app/models/user_model/user_model.dart';
import 'package:tsec_app/new_ui/screens/erp_screen/erp_screen.dart';
import 'package:tsec_app/new_ui/screens/home_screen/home_screen.dart';
import 'package:tsec_app/new_ui/screens/home_screen/widgets/home_widget.dart';
import 'package:tsec_app/new_ui/screens/main_screen/widgets/main_bottom_nav_bar.dart';
import 'package:tsec_app/new_ui/screens/profile_screen/profile_screen.dart';
import 'package:tsec_app/new_ui/screens/railway_screen/railway_screen.dart';
import 'package:tsec_app/new_ui/screens/timetable_screen/timetable_screen.dart';
import 'package:tsec_app/provider/appbar_title_provider.dart';
import 'package:tsec_app/provider/auth_provider.dart';
import 'package:tsec_app/provider/railway_concession_provider.dart';
import 'package:tsec_app/new_ui/screens/committees_screen/committees_screen.dart';
import 'package:tsec_app/screens/department_screen/department_screen.dart';
import 'package:tsec_app/screens/departmentlist_screen/department_list.dart';
import 'package:tsec_app/screens/tpc_screen.dart';
import 'package:tsec_app/utils/image_assets.dart';
import 'package:tsec_app/widgets/custom_scaffold.dart';
import 'package:url_launcher/link.dart';
import 'package:url_launcher/url_launcher.dart';

class MainScreen extends ConsumerStatefulWidget {
const MainScreen({
Expand Down Expand Up @@ -330,6 +325,7 @@ class _MainScreenState extends ConsumerState<MainScreen> {
),
),
onTap: () {
ref.read(titleProvider.notifier).state = 'TPC';
Navigator.pop(context);
Navigator.push(
context,
Expand All @@ -354,6 +350,7 @@ class _MainScreenState extends ConsumerState<MainScreen> {
),
),
onTap: () {
ref.read(titleProvider.notifier).state = 'Committees and Events';
/*setState(() {
currentPage = 6;
});*/
Expand Down Expand Up @@ -381,6 +378,7 @@ class _MainScreenState extends ConsumerState<MainScreen> {
),
),
onTap: () {
ref.read(titleProvider.notifier).state = 'Departments';
Navigator.pop(context);
Navigator.push(
context,
Expand Down
29 changes: 29 additions & 0 deletions lib/new_ui/screens/main_screen/widgets/common_basic_appbar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:tsec_app/provider/appbar_title_provider.dart';

class CommonAppbar extends ConsumerWidget implements PreferredSizeWidget{
const CommonAppbar({super.key});

@override
Size get preferredSize => Size.fromHeight(kToolbarHeight);

@override
Widget build(BuildContext context, WidgetRef ref) {
final title = ref.read(titleProvider);
return AppBar(
shadowColor: Colors.transparent,
backgroundColor: Colors.transparent,
toolbarHeight: 80,
title: Text(title,
style: Theme.of(context)
.textTheme
.headlineLarge!
.copyWith(fontSize: 15, color: Colors.white),
maxLines: 1,
overflow: TextOverflow.fade,),
centerTitle: true,
iconTheme: IconThemeData(color: Colors.white),
);
}
}
3 changes: 3 additions & 0 deletions lib/provider/appbar_title_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';

final titleProvider = StateProvider<String>((ref) => 'Default');
78 changes: 41 additions & 37 deletions lib/screens/departmentlist_screen/department_list.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:tsec_app/new_ui/screens/main_screen/widgets/common_basic_appbar.dart';
import 'package:tsec_app/screens/department_screen/widgets/department_screen_app_bar.dart';

import '../../utils/department_enum.dart';
Expand All @@ -23,43 +24,46 @@ class DepartmentList extends StatelessWidget {

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Department", style: Theme.of(context).textTheme.titleLarge),
),
const DeptWidget(
image: "aids",
department: DepartmentEnum.aids,
),
const DeptWidget(
image: "extc",
department: DepartmentEnum.extc,
),
const DeptWidget(
image: "cs",
department: DepartmentEnum.cs,
),
const DeptWidget(
image: "it",
department: DepartmentEnum.it,
),
const DeptWidget(
image: "biomed",
department: DepartmentEnum.biomed,
),
const DeptWidget(
image: "biotech",
department: DepartmentEnum.biotech,
),
const DeptWidget(
image: "chem",
department: DepartmentEnum.chem,
),
],
return Scaffold(
appBar: CommonAppbar(),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Department", style: Theme.of(context).textTheme.titleLarge),
),
const DeptWidget(
image: "aids",
department: DepartmentEnum.aids,
),
const DeptWidget(
image: "extc",
department: DepartmentEnum.extc,
),
const DeptWidget(
image: "cs",
department: DepartmentEnum.cs,
),
const DeptWidget(
image: "it",
department: DepartmentEnum.it,
),
const DeptWidget(
image: "biomed",
department: DepartmentEnum.biomed,
),
const DeptWidget(
image: "biotech",
department: DepartmentEnum.biotech,
),
const DeptWidget(
image: "chem",
department: DepartmentEnum.chem,
),
],
),
),
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/tpc_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:tsec_app/new_ui/screens/main_screen/widgets/common_basic_appbar.dart';

import '../models/company_model/company_model.dart';
import '../utils/image_assets.dart';
Expand Down Expand Up @@ -104,6 +105,7 @@ class _TPCScreenState extends State<TPCScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: CommonAppbar(),
body: NestedScrollView(
headerSliverBuilder: (_, __) => [
// SliverToBoxAdapter(
Expand Down

0 comments on commit 3bb8780

Please sign in to comment.