diff --git a/assets/resources/strings/pl.json b/assets/resources/strings/pl.json index f1e0a1a..1286ec6 100644 --- a/assets/resources/strings/pl.json +++ b/assets/resources/strings/pl.json @@ -1884,7 +1884,7 @@ }, { "id": "3A9D76DA-A971-48BB-B6F6-24D6A749D1F9", - "translation": "Dzisiaj nie ma lekcji!" + "translation": "Dzisiaj bez lekcji!" }, { "id": "F2A3AB37-ED80-478A-AF17-76BF541CE3D2", diff --git a/lib/interface/components/material/data_page.dart b/lib/interface/components/material/data_page.dart index 205b8ff..d709608 100644 --- a/lib/interface/components/material/data_page.dart +++ b/lib/interface/components/material/data_page.dart @@ -1,4 +1,5 @@ // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables +import 'package:autoscale_tabbarview/autoscale_tabbarview.dart'; import 'package:darq/darq.dart'; import 'package:dynamic_color/dynamic_color.dart'; import 'package:enum_flag/enum_flag.dart'; @@ -203,7 +204,26 @@ class DataPageState extends State with TickerProviderStateMixin { tabAlignment: (widget.segmentController?.scrollable ?? false) ? TabAlignment.center : TabAlignment.fill, labelPadding: EdgeInsets.symmetric(horizontal: 20), - tabs: widget.segments!.values.select((x, _) => Tab(text: x)).toList(), + tabs: widget.segments!.values + .select((x, index) => Tab( + text: (!Share.settings.appSettings.useCupertino && + isHorizontalPhoneMode(context) && + widget.pageBuilder != null) + ? null + : x, + child: (!Share.settings.appSettings.useCupertino && + isHorizontalPhoneMode(context) && + widget.pageBuilder != null) + ? Text(x, + style: TextStyle( + color: tabController.index == index + ? Theme.of(context).colorScheme.primary + : ((tabController.index - index).abs() < 4 + ? Theme.of(context).colorScheme.secondary + : Theme.of(context).colorScheme.onSurfaceVariant))) + : null, + )) + .toList(), controller: tabController, ) : null, @@ -214,23 +234,27 @@ class DataPageState extends State with TickerProviderStateMixin { ), if (widget.pageFlags.hasFlag(DataPageType.segmented) && widget.pageBuilder != null) SliverFillRemaining( - child: TabBarView( - controller: tabController, - viewportFraction: MediaQuery.of(context).size.width >= 640 ? (1 / 3) : 1.0, - children: List.generate(widget.segments!.length, - (index) => widget.pageBuilder!(context, widget.segments!.keys.elementAt(index))), - ), - // hasScrollBody: false, - // child: Column( - // children: [ - // AutoScaleTabBarView( - // controller: tabController, - // // viewportFraction: MediaQuery.of(context).size.width >= 640 ? (1 / 3) : 1.0, - // children: List.generate(widget.segments!.length, - // (index) => widget.pageBuilder!(context, widget.segments!.keys.elementAt(index))), - // ), - // ], - // ), + hasScrollBody: false, + child: isHorizontalPhoneMode(context) + ? SizedBox( + height: 2000, + child: TabBarView( + controller: tabController, + viewportFraction: isHorizontalPhoneMode(context) ? (1 / 7) : 1.0, + children: List.generate(widget.segments!.length, + (index) => widget.pageBuilder!(context, widget.segments!.keys.elementAt(index))), + ), + ) + : Column( + children: [ + AutoScaleTabBarView( + controller: tabController, + // viewportFraction: MediaQuery.of(context).size.width >= 640 ? (1 / 3) : 1.0, + children: List.generate(widget.segments!.length, + (index) => widget.pageBuilder!(context, widget.segments!.keys.elementAt(index))), + ), + ], + ), ), ], ); @@ -263,3 +287,7 @@ class DataPageState extends State with TickerProviderStateMixin { }); } } + +bool isHorizontalPhoneMode(BuildContext context) { + return MediaQuery.of(context).size.width >= 640 && MediaQuery.of(context).size.height < MediaQuery.of(context).size.width; +} diff --git a/lib/interface/components/material/elements/event.dart b/lib/interface/components/material/elements/event.dart index e201c8e..4cd209e 100644 --- a/lib/interface/components/material/elements/event.dart +++ b/lib/interface/components/material/elements/event.dart @@ -6,6 +6,7 @@ import 'package:format/format.dart'; import 'package:intl/intl.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; import 'package:oshi/interface/components/cupertino/application.dart'; +import 'package:oshi/interface/components/material/data_page.dart'; import 'package:oshi/interface/shared/containers.dart'; import 'package:oshi/interface/shared/input.dart'; import 'package:oshi/interface/shared/pages/home.dart'; @@ -373,7 +374,9 @@ extension EventWidgetExtension on Event { timeTo != null && timeTo?.hour != 0)) ])) .toList()))), - margin: EdgeInsets.only(left: 15, top: 5, bottom: 5, right: 20), + margin: !Share.settings.appSettings.useCupertino && isHorizontalPhoneMode(context) + ? EdgeInsets.only(left: 5, right: 5) + : EdgeInsets.only(left: 15, top: 5, bottom: 5, right: 20), child: ConstrainedBox( constraints: BoxConstraints( maxHeight: (animation?.value ?? 0) < CupertinoContextMenu.animationOpensAt ? double.infinity : 100, @@ -418,7 +421,10 @@ extension EventWidgetExtension on Event { flex: 2, child: Text( titleString, - maxLines: 1, + maxLines: + !Share.settings.appSettings.useCupertino && isHorizontalPhoneMode(context) + ? 3 + : 1, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 17, @@ -740,7 +746,9 @@ extension LessonWidgetExtension on TimetableLesson { isCanceled && !isMovedLesson)) ]), true)))), - margin: EdgeInsets.only(left: 15, top: 3, bottom: 3, right: 20), + margin: !Share.settings.appSettings.useCupertino && isHorizontalPhoneMode(context) + ? EdgeInsets.only(left: 5, right: 5) + : EdgeInsets.only(left: 15, top: 3, bottom: 3, right: 20), child: Opacity( opacity: (isCanceled || (date == DateTime.now().asDate() && diff --git a/lib/interface/shared/pages/timetable.dart b/lib/interface/shared/pages/timetable.dart index cc40edd..2d319c9 100644 --- a/lib/interface/shared/pages/timetable.dart +++ b/lib/interface/shared/pages/timetable.dart @@ -9,6 +9,7 @@ import 'package:flutter/material.dart'; import 'package:format/format.dart'; import 'package:intl/intl.dart'; import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; +import 'package:oshi/interface/components/material/data_page.dart'; import 'package:oshi/interface/components/shim/elements/event.dart'; import 'package:oshi/interface/components/shim/page_routes.dart'; import 'package:oshi/interface/shared/containers.dart'; @@ -167,52 +168,57 @@ class _TimetablePageState extends VisibilityAwareState { .toList(), ); - return Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - (searchController.text.isEmpty ? lessonsWidget : Container()), - if (!Share.settings.appSettings.useCupertino && - (homeworksToday.isNotEmpty || eventsToday.isNotEmpty || teachersAbsentToday.isNotEmpty)) - Padding( - padding: const EdgeInsets.only(bottom: 10), - child: Divider(indent: 23, endIndent: 23), - ), - // Homeworks for today - Visibility( - visible: homeworksToday.isNotEmpty, - child: Container( - margin: EdgeInsets.only(top: Share.settings.appSettings.useCupertino ? 20 : 0), - child: CardContainer( - filled: false, - regularOverride: true, - additionalDividerMargin: 5, - children: homeworksToday.isNotEmpty ? homeworksToday : [Text('')], - ))), - // Events for today - Visibility( - visible: eventsToday.isNotEmpty, - child: Container( - margin: EdgeInsets.only(top: Share.settings.appSettings.useCupertino ? 20 : 0), - child: CardContainer( - filled: false, - regularOverride: true, - additionalDividerMargin: 5, - children: eventsToday.isNotEmpty ? eventsToday : [Text('')], - ))), - // Teachers absent today - Visibility( - visible: teachersAbsentToday.isNotEmpty, - child: Container( - margin: EdgeInsets.only(top: Share.settings.appSettings.useCupertino ? 20 : 0), - child: CardContainer( - filled: false, - regularOverride: true, - additionalDividerMargin: 5, - children: teachersAbsentToday.isNotEmpty ? teachersAbsentToday : [Text('')], - ))), - ], + return MediaQuery( + data: MediaQuery.of(context).copyWith( + textScaler: + TextScaler.linear(!Share.settings.appSettings.useCupertino && isHorizontalPhoneMode(context) ? 0.7 : 1.0)), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + (searchController.text.isEmpty ? lessonsWidget : Container()), + if (!Share.settings.appSettings.useCupertino && + (homeworksToday.isNotEmpty || eventsToday.isNotEmpty || teachersAbsentToday.isNotEmpty)) + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Divider(indent: 23, endIndent: 23), + ), + // Homeworks for today + Visibility( + visible: homeworksToday.isNotEmpty, + child: Container( + margin: EdgeInsets.only(top: Share.settings.appSettings.useCupertino ? 20 : 0), + child: CardContainer( + filled: false, + regularOverride: true, + additionalDividerMargin: 5, + children: homeworksToday.isNotEmpty ? homeworksToday : [Text('')], + ))), + // Events for today + Visibility( + visible: eventsToday.isNotEmpty, + child: Container( + margin: EdgeInsets.only(top: Share.settings.appSettings.useCupertino ? 20 : 0), + child: CardContainer( + filled: false, + regularOverride: true, + additionalDividerMargin: 5, + children: eventsToday.isNotEmpty ? eventsToday : [Text('')], + ))), + // Teachers absent today + Visibility( + visible: teachersAbsentToday.isNotEmpty, + child: Container( + margin: EdgeInsets.only(top: Share.settings.appSettings.useCupertino ? 20 : 0), + child: CardContainer( + filled: false, + regularOverride: true, + additionalDividerMargin: 5, + children: teachersAbsentToday.isNotEmpty ? teachersAbsentToday : [Text('')], + ))), + ], + ), ); }