Skip to content

Commit

Permalink
Merge pull request #131 from sparcs-kaist/feat@page-route
Browse files Browse the repository at this point in the history
Add OTLNavigator and OTLScaffold
  • Loading branch information
sboh1214 authored Aug 20, 2023
2 parents 220fd98 + be266bc commit f67c6f1
Show file tree
Hide file tree
Showing 32 changed files with 1,428 additions and 1,437 deletions.
173 changes: 6 additions & 167 deletions lib/home.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:otlplus/providers/hall_of_fame_model.dart';
import 'package:otlplus/providers/course_search_model.dart';
import 'package:otlplus/providers/lecture_search_model.dart';
import 'package:otlplus/providers/timetable_model.dart';
import 'package:otlplus/utils/build_app_bar.dart';
import 'package:otlplus/utils/build_page_route.dart';
import 'package:otlplus/widgets/hall_of_fame_control.dart';
import 'package:otlplus/widgets/review_mode_control.dart';
import 'package:otlplus/widgets/timetable_mode_control.dart';
import 'package:otlplus/widgets/responsive_button.dart';
import 'package:otlplus/utils/navigator.dart';
import 'package:otlplus/widgets/otl_scaffold.dart';
import 'package:otlplus/widgets/pop_up.dart';
import 'package:otlplus/widgets/semester_picker.dart';
import 'package:provider/provider.dart';
import 'package:otlplus/constants/color.dart';
import 'package:otlplus/pages/dictionary_page.dart';
import 'package:otlplus/pages/main_page.dart';
import 'package:otlplus/pages/review_page.dart';
Expand Down Expand Up @@ -47,7 +35,7 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {
WidgetsBinding.instance.addPostFrameCallback(
(_) async {
if ((await SharedPreferences.getInstance()).getBool('popup') ?? true) {
await showDialog(
await OTLNavigator.pushDialog(
context: context,
builder: (context) => PopUp(),
);
Expand All @@ -58,12 +46,10 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: _buildAppBar(),
backgroundColor:
_currentIndex == 0 ? const Color(0xFF9B4810) : OTLColor.pinksLight,
return OTLScaffold(
// extendBodyBehindAppBar: _currentIndex == 0,
bottomNavigationBar: _buildBottomNavigationBar(),
body: GestureDetector(
child: GestureDetector(
onTap: () {
FocusScope.of(context).unfocus();
},
Expand All @@ -73,153 +59,6 @@ class _OTLHomeState extends State<OTLHome> with SingleTickerProviderStateMixin {
);
}

PreferredSizeWidget _buildHomeAppBar() {
return PreferredSize(
preferredSize: Size.fromHeight(5),
child: AppBar(
flexibleSpace:
SafeArea(child: Container(color: OTLColor.pinksMain, height: 5.0)),
backgroundColor: OTLColor.pinksLight,
foregroundColor: OTLColor.pinksMain,
elevation: 0.0,
automaticallyImplyLeading: false,
),
);
}

PreferredSizeWidget _buildTimeTableAppBar() {
return PreferredSize(
preferredSize: Size.fromHeight(kToolbarHeight + 5),
child: SafeArea(
child: Container(
color: OTLColor.pinksLight,
child: Column(
children: [
Container(
color: OTLColor.pinksMain,
height: 5,
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 16),
child: SemesterPicker(
onSemesterChanged: () {
context
.read<LectureSearchModel>()
.setSelectedLecture(null);
context.read<LectureSearchModel>().lectureClear();
},
),
),
TimetableModeControl(
dropdownIndex:
context.watch<TimetableModel>().selectedMode,
onTap: (mode) =>
context.read<TimetableModel>().setMode(mode),
),
],
),
)
],
),
),
),
);
}

PreferredSizeWidget _buildDictionaryAppBar() {
return AppBar(
title: appBarPadding(ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: BackgroundButton(
tapEffectColorRatio: 0.04,
onTap: () => Navigator.push(context, buildCourseSearchPageRoute()),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
child: Row(
children: [
SvgPicture.asset('assets/icons/search.svg',
height: 24.0,
width: 24.0,
colorFilter:
ColorFilter.mode(OTLColor.pinksMain, BlendMode.srcIn)),
const SizedBox(width: 12.0),
Expanded(
child: context.watch<CourseSearchModel>().courseSearchquery,
),
],
),
),
color: OTLColor.grayF,
),
)),
flexibleSpace:
SafeArea(child: Container(color: OTLColor.pinksMain, height: 5.0)),
toolbarHeight: kToolbarHeight + 5.0,
backgroundColor: OTLColor.pinksLight,
foregroundColor: OTLColor.gray0,
elevation: 0.0,
centerTitle: true,
automaticallyImplyLeading: false,
);
}

PreferredSizeWidget _buildReviewAppBar() {
return PreferredSize(
preferredSize: Size.fromHeight(kToolbarHeight + 5),
child: SafeArea(
child: Container(
color: OTLColor.pinksLight,
child: Column(
children: [
Container(
color: OTLColor.pinksMain,
height: 5,
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ReviewModeControl(
selectedMode:
context.watch<HallOfFameModel>().selectedMode,
),
Visibility(
visible:
context.watch<HallOfFameModel>().selectedMode == 0,
child: Padding(
padding: const EdgeInsets.only(right: 16.0),
child: HallOfFameControl(),
),
)
],
),
)
],
),
),
),
);
}

PreferredSizeWidget _buildAppBar() {
switch (_currentIndex) {
case 0:
return _buildHomeAppBar();
case 1:
return _buildTimeTableAppBar();
case 2:
return _buildDictionaryAppBar();
case 3:
return _buildReviewAppBar();
default:
return _buildHomeAppBar();
}
}

Widget _buildStack(BuildContext context, BoxConstraints constraints) {
final layerTop = constraints.biggest.height;
final layerAnimation = RelativeRectTween(
Expand Down
32 changes: 15 additions & 17 deletions lib/pages/course_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:otlplus/constants/text_styles.dart';
import 'package:otlplus/models/review.dart';
import 'package:otlplus/utils/build_app_bar.dart';
import 'package:otlplus/widgets/responsive_button.dart';
import 'package:otlplus/widgets/otl_scaffold.dart';
import 'package:provider/provider.dart';
import 'package:otlplus/constants/color.dart';
import 'package:otlplus/extensions/course.dart';
Expand All @@ -19,6 +19,7 @@ import 'package:otlplus/widgets/review_block.dart';
import 'package:otlplus/widgets/review_write_block.dart';

class CourseDetailPage extends StatelessWidget {
CourseDetailPage({Key? key}) : super(key: key);
static String route = 'course_detail_page';

final _scrollController = ScrollController();
Expand All @@ -29,17 +30,15 @@ class CourseDetailPage extends StatelessWidget {
context.watch<CourseDetailModel>();
final isEn = EasyLocalization.of(context)?.currentLocale == Locale('en');

return Scaffold(
appBar: buildAppBar(
context,
courseDetailModel.hasData
? (isEn
? courseDetailModel.course.titleEn
: courseDetailModel.course.title)
: '',
true,
false,
),
return OTLScaffold(
child: OTLLayout(
middle: Text(
courseDetailModel.hasData
? (isEn
? courseDetailModel.course.titleEn
: courseDetailModel.course.title)
: '',
style: titleBold),
body: Card(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16.0)),
Expand All @@ -50,7 +49,7 @@ class CourseDetailPage extends StatelessWidget {
child: const CircularProgressIndicator(),
),
),
);
));
}

Widget _buildBody(BuildContext context) {
Expand Down Expand Up @@ -323,10 +322,9 @@ class CourseDetailPage extends StatelessWidget {
),
);
return LectureGroupSimpleBlock(
lectures: filteredLectures,
semester: semester,
filter: selectedFilter,
);
lectures: filteredLectures,
semester: semester,
filter: selectedFilter);
},
).toList(),
),
Expand Down
Loading

0 comments on commit f67c6f1

Please sign in to comment.