Compare commits
No commits in common. "31aea64608c240a9fb820db038fcbe8011fc67b6" and "0647f260db754c98499dcf25f83df1230971240d" have entirely different histories.
31aea64608
...
0647f260db
17 changed files with 49 additions and 688 deletions
|
@ -1,8 +1,3 @@
|
||||||
v2.7.10
|
|
||||||
Add about page to Fluent UI.
|
|
||||||
Add settings page, allowing changing between UIs.
|
|
||||||
Add touch scrolling on Linux.
|
|
||||||
|
|
||||||
v2.7.9
|
v2.7.9
|
||||||
Add Fluent UI for Windows and Linux.
|
Add Fluent UI for Windows and Linux.
|
||||||
Add split view in landscape when viewing a train.
|
Add split view in landscape when viewing a train.
|
||||||
|
|
194
codemagic.yaml
194
codemagic.yaml
File diff suppressed because one or more lines are too long
|
@ -5,29 +5,19 @@ class CupertinoListTile extends StatelessWidget {
|
||||||
final Widget? title;
|
final Widget? title;
|
||||||
final Widget? subtitle;
|
final Widget? subtitle;
|
||||||
final Widget? trailing;
|
final Widget? trailing;
|
||||||
final void Function()? onTap;
|
|
||||||
|
|
||||||
const CupertinoListTile({ super.key, this.leading, this.title, this.subtitle, this.trailing, this.onTap, });
|
const CupertinoListTile({ Key? key, this.leading, this.title, this.subtitle, this.trailing, }) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return Row(
|
||||||
onTap: onTap,
|
|
||||||
behavior: HitTestBehavior.opaque,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
if (leading != null)
|
if (leading != null)
|
||||||
Padding(
|
leading!,
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: leading!,
|
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
if (title != null)
|
if (title != null)
|
||||||
title!,
|
title!,
|
||||||
|
@ -45,14 +35,9 @@ class CupertinoListTile extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
if (trailing != null)
|
if (trailing != null)
|
||||||
Padding(
|
trailing!,
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: trailing!,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,5 @@
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:fluent_ui/fluent_ui.dart' as f;
|
import 'package:fluent_ui/fluent_ui.dart' as f;
|
||||||
import 'package:flutter/cupertino.dart' as c;
|
import 'package:flutter/cupertino.dart' as c;
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart' as m;
|
import 'package:flutter/material.dart' as m;
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
@ -10,7 +7,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:info_tren/models.dart';
|
import 'package:info_tren/models.dart';
|
||||||
import 'package:info_tren/pages/about/about_page.dart';
|
import 'package:info_tren/pages/about/about_page.dart';
|
||||||
import 'package:info_tren/pages/main/main_page.dart';
|
import 'package:info_tren/pages/main/main_page.dart';
|
||||||
import 'package:info_tren/pages/settings/setings_page.dart';
|
|
||||||
import 'package:info_tren/pages/station_arrdep_page/select_station/select_station.dart';
|
import 'package:info_tren/pages/station_arrdep_page/select_station/select_station.dart';
|
||||||
import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart';
|
import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart';
|
||||||
import 'package:info_tren/pages/train_info_page/view_train/train_info.dart';
|
import 'package:info_tren/pages/train_info_page/view_train/train_info.dart';
|
||||||
|
@ -37,9 +33,6 @@ Map<String, WidgetBuilder> get routes => {
|
||||||
AboutPage.routeName: (context) {
|
AboutPage.routeName: (context) {
|
||||||
return const AboutPage();
|
return const AboutPage();
|
||||||
},
|
},
|
||||||
SettingsPage.routeName: (context) {
|
|
||||||
return const SettingsPage();
|
|
||||||
},
|
|
||||||
SelectTrainPage.routeName: (context) {
|
SelectTrainPage.routeName: (context) {
|
||||||
return const SelectTrainPage();
|
return const SelectTrainPage();
|
||||||
},
|
},
|
||||||
|
@ -66,36 +59,6 @@ Map<String, WidgetBuilder> get routes => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
class DragFluentScrollBevahior extends f.FluentScrollBehavior {
|
|
||||||
const DragFluentScrollBevahior();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Set<PointerDeviceKind> get dragDevices => {
|
|
||||||
PointerDeviceKind.mouse,
|
|
||||||
PointerDeviceKind.touch,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class DragCupertinoScrollBevahior extends c.CupertinoScrollBehavior {
|
|
||||||
const DragCupertinoScrollBevahior();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Set<PointerDeviceKind> get dragDevices => {
|
|
||||||
PointerDeviceKind.mouse,
|
|
||||||
PointerDeviceKind.touch,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class DragMaterialScrollBevahior extends m.MaterialScrollBehavior {
|
|
||||||
const DragMaterialScrollBevahior();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Set<PointerDeviceKind> get dragDevices => {
|
|
||||||
PointerDeviceKind.mouse,
|
|
||||||
PointerDeviceKind.touch,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class StartPoint extends ConsumerWidget {
|
class StartPoint extends ConsumerWidget {
|
||||||
final String appTitle = 'Info Tren';
|
final String appTitle = 'Info Tren';
|
||||||
|
|
||||||
|
@ -120,7 +83,6 @@ class StartPoint extends ConsumerWidget {
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
),
|
),
|
||||||
scrollBehavior: Platform.isLinux ? const DragCupertinoScrollBevahior() : null,
|
|
||||||
routes: routes,
|
routes: routes,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -133,7 +95,6 @@ class StartPoint extends ConsumerWidget {
|
||||||
accentColor: f.Colors.blue,
|
accentColor: f.Colors.blue,
|
||||||
),
|
),
|
||||||
routes: routes,
|
routes: routes,
|
||||||
scrollBehavior: Platform.isLinux ? const DragFluentScrollBevahior() : const f.FluentScrollBehavior(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -149,7 +110,6 @@ class StartPoint extends ConsumerWidget {
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
// fontFamily: 'Atkinson Hyperlegible',
|
// fontFamily: 'Atkinson Hyperlegible',
|
||||||
),
|
),
|
||||||
scrollBehavior: Platform.isLinux ? const DragMaterialScrollBevahior() : null,
|
|
||||||
routes: routes,
|
routes: routes,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,6 @@ enum UiDesign {
|
||||||
FLUENT,
|
FLUENT,
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UIName on UiDesign {
|
|
||||||
String get userInterfaceName => (const {
|
|
||||||
UiDesign.MATERIAL: 'Material',
|
|
||||||
UiDesign.CUPERTINO: 'Cupertino',
|
|
||||||
UiDesign.FLUENT: 'Fluent',
|
|
||||||
})[this]!;
|
|
||||||
}
|
|
||||||
|
|
||||||
class UnmatchedUiDesignException implements Exception {
|
class UnmatchedUiDesignException implements Exception {
|
||||||
final UiDesign uiDesign;
|
final UiDesign uiDesign;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:info_tren/api/releases.dart';
|
import 'package:info_tren/api/releases.dart';
|
||||||
import 'package:info_tren/models.dart';
|
import 'package:info_tren/models.dart';
|
||||||
import 'package:info_tren/pages/about/about_page_cupertino.dart';
|
import 'package:info_tren/pages/about/about_page_cupertino.dart';
|
||||||
import 'package:info_tren/pages/about/about_page_fluent.dart';
|
|
||||||
import 'package:info_tren/pages/about/about_page_material.dart';
|
import 'package:info_tren/pages/about/about_page_material.dart';
|
||||||
import 'package:info_tren/providers.dart';
|
import 'package:info_tren/providers.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
@ -22,8 +21,6 @@ class AboutPage extends ConsumerWidget {
|
||||||
return const AboutPageMaterial();
|
return const AboutPageMaterial();
|
||||||
case UiDesign.CUPERTINO:
|
case UiDesign.CUPERTINO:
|
||||||
return const AboutPageCupertino();
|
return const AboutPageCupertino();
|
||||||
case UiDesign.FLUENT:
|
|
||||||
return const AboutPageFluent();
|
|
||||||
default:
|
default:
|
||||||
throw UnmatchedUiDesignException(uiDesign);
|
throw UnmatchedUiDesignException(uiDesign);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +31,7 @@ abstract class AboutPageShared extends StatefulWidget {
|
||||||
const AboutPageShared({super.key});
|
const AboutPageShared({super.key});
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class AboutPageState<T extends AboutPageShared> extends State<T> {
|
abstract class AboutPageState extends State<AboutPageShared> {
|
||||||
static const String download = String.fromEnvironment('DOWNLOAD');
|
static const String download = String.fromEnvironment('DOWNLOAD');
|
||||||
|
|
||||||
final String pageTitle = 'Despre aplicație';
|
final String pageTitle = 'Despre aplicație';
|
||||||
|
|
|
@ -3,14 +3,14 @@ import 'package:info_tren/components/cupertino_divider.dart';
|
||||||
import 'package:info_tren/pages/about/about_page.dart';
|
import 'package:info_tren/pages/about/about_page.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class AboutPageCupertino extends AboutPageShared {
|
class AboutPageCupertino extends StatefulWidget {
|
||||||
const AboutPageCupertino({super.key});
|
const AboutPageCupertino({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AboutPageShared> createState() => AboutPageStateCupertino();
|
State<AboutPageShared> createState() => AboutPageStateCupertino();
|
||||||
}
|
}
|
||||||
|
|
||||||
class AboutPageStateCupertino extends AboutPageState<AboutPageCupertino> {
|
class AboutPageStateCupertino extends AboutPageState {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
|
|
|
@ -1,140 +0,0 @@
|
||||||
import 'package:fluent_ui/fluent_ui.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:info_tren/pages/about/about_page.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
class AboutPageFluent extends AboutPageShared {
|
|
||||||
const AboutPageFluent({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<AboutPageShared> createState() => AboutPageStateFluent();
|
|
||||||
}
|
|
||||||
|
|
||||||
class AboutPageStateFluent extends AboutPageState<AboutPageFluent> {
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return NavigationView(
|
|
||||||
appBar: NavigationAppBar(
|
|
||||||
title: Text(pageTitle),
|
|
||||||
),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
Center(
|
|
||||||
child: Text(
|
|
||||||
'Info Tren',
|
|
||||||
style: FluentTheme.of(context).typography.display,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (packageInfo != null)
|
|
||||||
Center(
|
|
||||||
child: Text(
|
|
||||||
packageInfo!.packageName,
|
|
||||||
style: FluentTheme.of(context).typography.caption,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// ListTile(
|
|
||||||
// title: Text(versionTitleText),
|
|
||||||
// subtitle: localChangelog.isEmpty ? null : Text(localChangelog.first.title),
|
|
||||||
// ),
|
|
||||||
const Divider(),
|
|
||||||
for (final log in mergedChangelogs) ...[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
log.version.toString(),
|
|
||||||
style: FluentTheme.of(context).typography.title,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (localChangelog.isNotEmpty && log.version == localChangelog.first.version)
|
|
||||||
Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: FluentTheme.of(context).inactiveColor,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(4),
|
|
||||||
child: Text(
|
|
||||||
currentVersionText,
|
|
||||||
style: const TextStyle(
|
|
||||||
inherit: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (remoteChangelog.isNotEmpty && log.version == remoteChangelog.first.version && (localChangelog.isEmpty || localChangelog.first.version != log.version))
|
|
||||||
Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.green,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(4),
|
|
||||||
child: Text(
|
|
||||||
latestVersionText,
|
|
||||||
style: TextStyle(
|
|
||||||
inherit: true,
|
|
||||||
color: Colors.green,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (AboutPageState.download == 'apk' && log.apkLink != null)
|
|
||||||
GestureDetector(
|
|
||||||
onSecondaryTap: () {
|
|
||||||
Clipboard.setData(ClipboardData(text: log.apkLink!.toString()));
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
|
||||||
// content: Text('Link copied to clipboard'),
|
|
||||||
// ));
|
|
||||||
},
|
|
||||||
onLongPress: () {
|
|
||||||
Clipboard.setData(ClipboardData(text: log.apkLink!.toString()));
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
|
||||||
// content: Text('Link copied to clipboard'),
|
|
||||||
// ));
|
|
||||||
},
|
|
||||||
onTap: () {
|
|
||||||
launchUrl(
|
|
||||||
log.apkLink!,
|
|
||||||
mode: LaunchMode.externalApplication,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
behavior: HitTestBehavior.translucent,
|
|
||||||
child: const Tooltip(
|
|
||||||
message: 'Download APK',
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.all(4),
|
|
||||||
child: Icon(FluentIcons.download),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
text: log.description,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,14 +3,14 @@ import 'package:flutter/services.dart';
|
||||||
import 'package:info_tren/pages/about/about_page.dart';
|
import 'package:info_tren/pages/about/about_page.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class AboutPageMaterial extends AboutPageShared {
|
class AboutPageMaterial extends StatefulWidget {
|
||||||
const AboutPageMaterial({super.key});
|
const AboutPageMaterial({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AboutPageShared> createState() => AboutPageStateMaterial();
|
State<AboutPageShared> createState() => AboutPageStateMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
class AboutPageStateMaterial extends AboutPageState<AboutPageMaterial> {
|
class AboutPageStateMaterial extends AboutPageState {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|
|
@ -5,7 +5,6 @@ import 'package:info_tren/pages/about/about_page.dart';
|
||||||
import 'package:info_tren/pages/main/main_page_cupertino.dart';
|
import 'package:info_tren/pages/main/main_page_cupertino.dart';
|
||||||
import 'package:info_tren/pages/main/main_page_fluent.dart';
|
import 'package:info_tren/pages/main/main_page_fluent.dart';
|
||||||
import 'package:info_tren/pages/main/main_page_material.dart';
|
import 'package:info_tren/pages/main/main_page_material.dart';
|
||||||
import 'package:info_tren/pages/settings/setings_page.dart';
|
|
||||||
import 'package:info_tren/pages/station_arrdep_page/select_station/select_station.dart';
|
import 'package:info_tren/pages/station_arrdep_page/select_station/select_station.dart';
|
||||||
import 'package:info_tren/pages/train_info_page/select_train/select_train.dart';
|
import 'package:info_tren/pages/train_info_page/select_train/select_train.dart';
|
||||||
import 'package:info_tren/providers.dart';
|
import 'package:info_tren/providers.dart';
|
||||||
|
@ -37,12 +36,6 @@ abstract class MainPageShared extends StatelessWidget {
|
||||||
const MainPageShared({super.key});
|
const MainPageShared({super.key});
|
||||||
|
|
||||||
List<MainPageAction> get popupMenu => [
|
List<MainPageAction> get popupMenu => [
|
||||||
MainPageAction(
|
|
||||||
name: 'Setări',
|
|
||||||
action: (context) {
|
|
||||||
Navigator.of(context).pushNamed(SettingsPage.routeName);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
MainPageAction(
|
MainPageAction(
|
||||||
name: 'Despre aplicație',
|
name: 'Despre aplicație',
|
||||||
action: (context) {
|
action: (context) {
|
||||||
|
@ -92,9 +85,5 @@ class MainPageAction {
|
||||||
final String? description;
|
final String? description;
|
||||||
final void Function(BuildContext context)? action;
|
final void Function(BuildContext context)? action;
|
||||||
|
|
||||||
MainPageAction({
|
MainPageAction({required this.name, this.action, this.description});
|
||||||
required this.name,
|
|
||||||
this.action,
|
|
||||||
this.description,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,6 @@ class MainPageFluent extends MainPageShared {
|
||||||
appBar: NavigationAppBar(
|
appBar: NavigationAppBar(
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
title: Text(pageTitle),
|
title: Text(pageTitle),
|
||||||
actions: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: popupMenu.map((i) => Center(
|
|
||||||
child: SizedBox(
|
|
||||||
width: 32,
|
|
||||||
height: 32,
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon({
|
|
||||||
'Setări': FluentIcons.settings,
|
|
||||||
'Despre aplicație': FluentIcons.info,
|
|
||||||
}[i.name]),
|
|
||||||
onPressed: i.action != null ? () => i.action!(context) : null,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)).toList(),
|
|
||||||
),
|
|
||||||
// centerTitle: true,
|
// centerTitle: true,
|
||||||
// actions: [
|
// actions: [
|
||||||
// PopupMenuButton<int>(
|
// PopupMenuButton<int>(
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:info_tren/models.dart';
|
|
||||||
import 'package:info_tren/pages/settings/settings_page_cupertino.dart';
|
|
||||||
import 'package:info_tren/pages/settings/settings_page_fluent.dart';
|
|
||||||
import 'package:info_tren/pages/settings/settings_page_material.dart';
|
|
||||||
import 'package:info_tren/providers.dart';
|
|
||||||
|
|
||||||
class SettingsPage extends ConsumerWidget {
|
|
||||||
const SettingsPage({super.key,});
|
|
||||||
|
|
||||||
static const String routeName = '/settings';
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final uiDesign = ref.watch(uiDesignProvider);
|
|
||||||
|
|
||||||
switch (uiDesign) {
|
|
||||||
case UiDesign.MATERIAL:
|
|
||||||
return const SettingsPageMaterial();
|
|
||||||
case UiDesign.CUPERTINO:
|
|
||||||
return const SettingsPageCupertino();
|
|
||||||
case UiDesign.FLUENT:
|
|
||||||
return const SettingsPageFluent();
|
|
||||||
default:
|
|
||||||
throw UnmatchedUiDesignException(uiDesign);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class SettingsPageShared extends StatelessWidget {
|
|
||||||
final String pageTitle = 'Setări';
|
|
||||||
final String appearanceTitle = 'Aspect';
|
|
||||||
|
|
||||||
const SettingsPageShared({super.key});
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:info_tren/components/cupertino_listtile.dart';
|
|
||||||
import 'package:info_tren/models.dart';
|
|
||||||
import 'package:info_tren/pages/settings/setings_page.dart';
|
|
||||||
import 'package:info_tren/providers.dart';
|
|
||||||
|
|
||||||
class SettingsPageCupertino extends SettingsPageShared {
|
|
||||||
const SettingsPageCupertino({super.key,});
|
|
||||||
|
|
||||||
Future<T?> singleChoice<T>({required BuildContext context, required List<T> choices, required String Function(T) labelBuilder, String? title}) async {
|
|
||||||
return await showCupertinoModalPopup<T>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return CupertinoActionSheet(
|
|
||||||
title: title != null ? Text(title) : null,
|
|
||||||
actions: choices.map((c) => CupertinoActionSheetAction(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop(c);
|
|
||||||
},
|
|
||||||
child: Text(labelBuilder(c)),
|
|
||||||
)).toList(),
|
|
||||||
cancelButton: CupertinoActionSheetAction(
|
|
||||||
child: const Text('Anulare'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return CupertinoPageScaffold(
|
|
||||||
navigationBar: CupertinoNavigationBar(
|
|
||||||
previousPageTitle: 'Info Tren',
|
|
||||||
middle: Text(pageTitle),
|
|
||||||
),
|
|
||||||
child: Builder(
|
|
||||||
builder: (context) {
|
|
||||||
final mq = MediaQuery.of(context);
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: mq.padding.top,
|
|
||||||
),
|
|
||||||
Consumer(
|
|
||||||
builder: (context, ref, _) {
|
|
||||||
final currentUiDesign = ref.watch(uiDesignProvider);
|
|
||||||
return CupertinoListTile(
|
|
||||||
title: Text(appearanceTitle),
|
|
||||||
trailing: Text(currentUiDesign.userInterfaceName),
|
|
||||||
onTap: () async {
|
|
||||||
final choice = await singleChoice(
|
|
||||||
context: context,
|
|
||||||
choices: UiDesign.values,
|
|
||||||
labelBuilder: (UiDesign ud) => ud.userInterfaceName,
|
|
||||||
title: appearanceTitle,
|
|
||||||
);
|
|
||||||
if (choice != null) {
|
|
||||||
ref.read(uiDesignProvider.notifier).set(choice);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
import 'package:fluent_ui/fluent_ui.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:info_tren/models.dart';
|
|
||||||
import 'package:info_tren/pages/settings/setings_page.dart';
|
|
||||||
import 'package:info_tren/providers.dart';
|
|
||||||
|
|
||||||
class SettingsPageFluent extends SettingsPageShared {
|
|
||||||
const SettingsPageFluent({super.key,});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return NavigationView(
|
|
||||||
appBar: NavigationAppBar(
|
|
||||||
title: Text(pageTitle),
|
|
||||||
),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Consumer(
|
|
||||||
builder: (context, ref, _) {
|
|
||||||
final currentUiDesign = ref.watch(uiDesignProvider);
|
|
||||||
return ListTile(
|
|
||||||
title: Text(appearanceTitle),
|
|
||||||
trailing: ComboBox<UiDesign>(
|
|
||||||
items: UiDesign.values.map((d) => ComboBoxItem(
|
|
||||||
value: d,
|
|
||||||
child: Text(d.userInterfaceName),
|
|
||||||
)).toList(),
|
|
||||||
value: currentUiDesign,
|
|
||||||
onChanged: (newUiDesign) {
|
|
||||||
ref.read(uiDesignProvider.notifier).set(newUiDesign);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:info_tren/models.dart';
|
|
||||||
import 'package:info_tren/pages/settings/setings_page.dart';
|
|
||||||
import 'package:info_tren/providers.dart';
|
|
||||||
|
|
||||||
class SettingsPageMaterial extends SettingsPageShared {
|
|
||||||
const SettingsPageMaterial({super.key,});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: Text(pageTitle),
|
|
||||||
centerTitle: true,
|
|
||||||
),
|
|
||||||
body: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Consumer(
|
|
||||||
builder: (context, ref, _) {
|
|
||||||
final currentUiDesign = ref.watch(uiDesignProvider);
|
|
||||||
return ListTile(
|
|
||||||
title: Text(appearanceTitle),
|
|
||||||
trailing: DropdownButton<UiDesign>(
|
|
||||||
items: UiDesign.values.map((d) => DropdownMenuItem(
|
|
||||||
value: d,
|
|
||||||
child: Text(d.userInterfaceName),
|
|
||||||
)).toList(),
|
|
||||||
value: currentUiDesign,
|
|
||||||
onChanged: (newUiDesign) {
|
|
||||||
ref.read(uiDesignProvider.notifier).set(newUiDesign);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,30 +13,22 @@ final sharedPreferencesProvider = Provider<SharedPreferences>(
|
||||||
(_) => throw UnimplementedError('Please override in ProviderScope'),
|
(_) => throw UnimplementedError('Please override in ProviderScope'),
|
||||||
);
|
);
|
||||||
|
|
||||||
class UiDesignNotifier extends StateNotifier<UiDesign> {
|
final uiDesignProvider = Provider((ref) {
|
||||||
final SharedPreferences sharedPreferences;
|
final sharedPreferences = ref.watch(sharedPreferencesProvider);
|
||||||
|
|
||||||
UiDesignNotifier({required this.sharedPreferences,}) : super(UiDesign.MATERIAL) {
|
|
||||||
final stored = sharedPreferences.getString('uiDesign');
|
final stored = sharedPreferences.getString('uiDesign');
|
||||||
final design = UiDesign.values.where((element) => element.name == stored).firstOrNull ?? defaultUiDesign;
|
final design = UiDesign.values.where((element) => element.name == stored).firstOrNull ?? defaultUiDesign;
|
||||||
state = design;
|
return design;
|
||||||
}
|
});
|
||||||
|
Future<void> setUiDesign(Ref ref, UiDesign? design) async {
|
||||||
void set(UiDesign? design) async {
|
final sharedPreferences = ref.watch(sharedPreferencesProvider);
|
||||||
if (design != null) {
|
if (design != null) {
|
||||||
await sharedPreferences.setString('uiDesign', design.name);
|
await sharedPreferences.setString('uiDesign', design.name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await sharedPreferences.remove('uiDesign');
|
await sharedPreferences.remove('uiDesign');
|
||||||
}
|
}
|
||||||
state = design ?? defaultUiDesign;
|
ref.invalidate(uiDesignProvider);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
final uiDesignProvider = StateNotifierProvider<UiDesignNotifier, UiDesign>(
|
|
||||||
(ref) => UiDesignNotifier(
|
|
||||||
sharedPreferences: ref.watch(sharedPreferencesProvider),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final trainInfoArgumentsProvider = Provider<TrainInfoArguments>(
|
final trainInfoArgumentsProvider = Provider<TrainInfoArguments>(
|
||||||
(_) => throw UnimplementedError('Please override in ProviderScope'),
|
(_) => throw UnimplementedError('Please override in ProviderScope'),
|
||||||
|
|
|
@ -11,7 +11,7 @@ description: O aplicație de vizualizare a datelor puse la dispoziție de Inform
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 2.7.10
|
version: 2.7.9
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.0 <3.0.0"
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue