moved non-premium features from premium folder
This commit is contained in:
218
filcnaplo_mobile_ui/lib/pages/timetable/fs_timetable.dart
Normal file
218
filcnaplo_mobile_ui/lib/pages/timetable/fs_timetable.dart
Normal file
@@ -0,0 +1,218 @@
|
||||
import 'package:filcnaplo/helpers/subject.dart';
|
||||
import 'package:filcnaplo/models/settings.dart';
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:filcnaplo_kreta_api/controllers/timetable_controller.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/empty.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:filcnaplo/utils/format.dart';
|
||||
import 'dart:math' as math;
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:i18n_extension/i18n_widget.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class FSTimetable extends StatefulWidget {
|
||||
const FSTimetable({Key? key, required this.controller})
|
||||
: super(key: key);
|
||||
|
||||
final TimetableController controller;
|
||||
|
||||
@override
|
||||
State<FSTimetable> createState() => _FSTimetableState();
|
||||
}
|
||||
|
||||
class _FSTimetableState extends State<FSTimetable> {
|
||||
late SettingsProvider settings;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.landscapeLeft,
|
||||
]);
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
settings = Provider.of<SettingsProvider>(context);
|
||||
|
||||
if (widget.controller.days == null || widget.controller.days!.isEmpty) {
|
||||
return const Center(child: Empty());
|
||||
}
|
||||
|
||||
final days = widget.controller.days!;
|
||||
final everyLesson = days.expand((x) => x).toList();
|
||||
everyLesson.sort((a, b) => a.start.compareTo(b.start));
|
||||
|
||||
final int maxLessonCount = days.fold(
|
||||
0,
|
||||
(a, b) => math.max(
|
||||
a, b.where((l) => l.subject.id != "" || l.isEmpty).length));
|
||||
|
||||
const prefixw = 40;
|
||||
const padding = prefixw + 6 * 2;
|
||||
final colw = (MediaQuery.of(context).size.width - padding) / days.length;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
leading: BackButton(color: AppColors.of(context).text),
|
||||
shadowColor: Colors.transparent,
|
||||
),
|
||||
body: ListView.builder(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 24.0),
|
||||
itemCount: maxLessonCount + 1,
|
||||
itemBuilder: (context, index) {
|
||||
List<Widget> columns = [];
|
||||
for (int dayIndex = -1; dayIndex < days.length; dayIndex++) {
|
||||
if (dayIndex == -1) {
|
||||
if (index >= 1) {
|
||||
columns.add(SizedBox(
|
||||
width: prefixw.toDouble(),
|
||||
height: 40.0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(
|
||||
(index).toString()+".",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.secondary),
|
||||
),
|
||||
),
|
||||
));
|
||||
} else {
|
||||
columns.add(SizedBox(width: prefixw.toDouble()));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
final lessons = days[dayIndex]
|
||||
.where((l) => l.subject.id != "" || l.isEmpty)
|
||||
.toList();
|
||||
|
||||
if (lessons.isEmpty) continue;
|
||||
|
||||
final dayOffset = int.tryParse(lessons.first.lessonIndex) ?? 0;
|
||||
|
||||
if (index == 0 && dayIndex >= 0) {
|
||||
columns.add(
|
||||
SizedBox(
|
||||
width: colw,
|
||||
height: 40.0,
|
||||
child: Text(
|
||||
DateFormat("EEEE", I18n.of(context).locale.languageCode)
|
||||
.format(lessons.first.date)
|
||||
.capital(),
|
||||
style: const TextStyle(
|
||||
fontSize: 24.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
final lessonIndex = index - dayOffset;
|
||||
|
||||
if (lessonIndex < 0 || lessonIndex >= lessons.length) {
|
||||
columns.add(SizedBox(width: colw));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lessons[lessonIndex].isEmpty) {
|
||||
columns.add(
|
||||
SizedBox(
|
||||
width: colw,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Icon(
|
||||
FeatherIcons.slash,
|
||||
size: 18.0,
|
||||
color: AppColors.of(context).text.withOpacity(.3),
|
||||
),
|
||||
const SizedBox(width: 8.0),
|
||||
Text(
|
||||
"Lyukas óra",
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context).text.withOpacity(.3),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
columns.add(
|
||||
SizedBox(
|
||||
width: colw,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
SubjectIcon.resolveVariant(
|
||||
context: context,
|
||||
subject: lessons[lessonIndex].subject,
|
||||
),
|
||||
size: 18.0,
|
||||
color: AppColors.of(context).text.withOpacity(.7),
|
||||
),
|
||||
const SizedBox(width: 8.0),
|
||||
Expanded(
|
||||
child: Text(
|
||||
lessons[lessonIndex].subject.renamedTo ??
|
||||
lessons[lessonIndex].subject.name.capital(),
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
fontStyle: lessons[lessonIndex]
|
||||
.subject
|
||||
.isRenamed && settings.renamedSubjectsItalics
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
softWrap: false,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 15),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 26.0),
|
||||
child: Text(
|
||||
lessons[lessonIndex].room,
|
||||
style: TextStyle(
|
||||
color: AppColors.of(context).text.withOpacity(.5),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: columns,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,19 +12,21 @@ import 'package:filcnaplo_mobile_ui/common/empty.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/panel/panel.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/profile_image/profile_button.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/profile_image/profile_image.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/system_chrome.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/lesson/lesson_view.dart';
|
||||
import 'package:filcnaplo_kreta_api/controllers/timetable_controller.dart';
|
||||
import 'package:filcnaplo_mobile_ui/common/widgets/lesson/lesson_viewable.dart';
|
||||
import 'package:filcnaplo_mobile_ui/pages/timetable/day_title.dart';
|
||||
import 'package:filcnaplo_mobile_ui/pages/timetable/fs_timetable.dart';
|
||||
import 'package:filcnaplo_mobile_ui/screens/navigation/navigation_route_handler.dart';
|
||||
import 'package:filcnaplo_mobile_ui/screens/navigation/navigation_screen.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:i18n_extension/i18n_widget.dart';
|
||||
import 'package:filcnaplo_premium/ui/mobile/timetable/fs_timetable_button.dart';
|
||||
import 'timetable_page.i18n.dart';
|
||||
|
||||
// todo: "fix" overflow (priority: -1)
|
||||
@@ -199,7 +201,38 @@ class _TimetablePageState extends State<TimetablePage>
|
||||
snap: false,
|
||||
surfaceTintColor: Theme.of(context).scaffoldBackgroundColor,
|
||||
actions: [
|
||||
PremiumFSTimetableButton(controller: _controller, tabcontroller: _tabController),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: IconButton(
|
||||
splashRadius: 24.0,
|
||||
onPressed: () {
|
||||
// If timetable empty, show empty
|
||||
if (_tabController.length == 0) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text("empty_timetable".i18n),
|
||||
duration: const Duration(seconds: 2),
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
Navigator.of(context, rootNavigator: true)
|
||||
.push(PageRouteBuilder(
|
||||
pageBuilder:
|
||||
(context, animation, secondaryAnimation) =>
|
||||
FSTimetable(
|
||||
controller: _controller,
|
||||
),
|
||||
))
|
||||
.then((_) {
|
||||
SystemChrome.setPreferredOrientations(
|
||||
[DeviceOrientation.portraitUp]);
|
||||
setSystemChrome(context);
|
||||
});
|
||||
},
|
||||
icon: Icon(FeatherIcons.trello,
|
||||
color: AppColors.of(context).text),
|
||||
),
|
||||
),
|
||||
|
||||
// Profile Icon
|
||||
Padding(
|
||||
|
||||
Reference in New Issue
Block a user