moved non-premium features from premium folder
This commit is contained in:
105
filcnaplo_mobile_ui/lib/pages/grades/average_selector.dart
Normal file
105
filcnaplo_mobile_ui/lib/pages/grades/average_selector.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'package:filcnaplo/theme/colors/colors.dart';
|
||||
import 'package:filcnaplo_premium/models/premium_scopes.dart';
|
||||
import 'package:filcnaplo_premium/providers/premium_provider.dart';
|
||||
import 'package:filcnaplo_premium/ui/mobile/premium/upsell.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:dropdown_button2/dropdown_button2.dart';
|
||||
import 'package:filcnaplo_mobile_ui/pages/grades/grades_page.i18n.dart';
|
||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
final Map<int, String> avgDropItems = {
|
||||
0: "annual_average",
|
||||
90: "3_months_average",
|
||||
30: "30_days_average",
|
||||
14: "14_days_average",
|
||||
7: "7_days_average",
|
||||
};
|
||||
|
||||
class AverageSelector extends StatefulWidget {
|
||||
const AverageSelector({Key? key, this.onChanged, required this.value}) : super(key: key);
|
||||
|
||||
final Function(int?)? onChanged;
|
||||
final int value;
|
||||
|
||||
@override
|
||||
_AverageSelectorState createState() => _AverageSelectorState();
|
||||
}
|
||||
|
||||
class _AverageSelectorState extends State<AverageSelector> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<DropdownMenuItem<int>> dropdownItems = avgDropItems.keys.map((item) {
|
||||
return DropdownMenuItem<int>(
|
||||
value: item,
|
||||
child: Text(
|
||||
avgDropItems[item]!.i18n,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.of(context).text,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
|
||||
return DropdownButton2<int>(
|
||||
items: dropdownItems,
|
||||
onChanged: (int? value) {
|
||||
if (Provider.of<PremiumProvider>(context, listen: false).hasScope(PremiumScopes.gradeStats)) {
|
||||
if (widget.onChanged != null) {
|
||||
setState(() {
|
||||
widget.onChanged!(value);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
PremiumLockedFeatureUpsell.show(context: context, feature: PremiumFeature.gradestats);
|
||||
}
|
||||
},
|
||||
value: widget.value,
|
||||
iconSize: 14,
|
||||
iconEnabledColor: AppColors.of(context).text,
|
||||
iconDisabledColor: AppColors.of(context).text,
|
||||
underline: const SizedBox(),
|
||||
itemHeight: 40,
|
||||
itemPadding: const EdgeInsets.only(left: 14, right: 14),
|
||||
dropdownWidth: 200,
|
||||
dropdownPadding: null,
|
||||
buttonDecoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
dropdownDecoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
),
|
||||
dropdownElevation: 8,
|
||||
scrollbarRadius: const Radius.circular(40),
|
||||
scrollbarThickness: 6,
|
||||
scrollbarAlwaysShow: true,
|
||||
offset: const Offset(-10, -10),
|
||||
buttonSplashColor: Colors.transparent,
|
||||
customButton: SizedBox(
|
||||
height: 30,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
avgDropItems[widget.value]!.i18n,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall!
|
||||
.copyWith(fontWeight: FontWeight.w600, color: AppColors.of(context).text.withOpacity(0.65)),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
Icon(
|
||||
FeatherIcons.chevronDown,
|
||||
size: 16,
|
||||
color: AppColors.of(context).text,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import 'package:filcnaplo_premium/providers/premium_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:filcnaplo/helpers/average_helper.dart';
|
||||
import 'package:filcnaplo_premium/ui/mobile/grades/average_selector.dart';
|
||||
import 'average_selector.dart';
|
||||
import 'package:filcnaplo_premium/ui/mobile/premium/premium_inline.dart';
|
||||
import 'grades_page.i18n.dart';
|
||||
|
||||
@@ -240,7 +240,7 @@ class _GradesPageState extends State<GradesPage> {
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
PremiumAverageSelector(
|
||||
AverageSelector(
|
||||
value: avgDropValue,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
|
||||
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