finished calendar sync settings part

This commit is contained in:
Kima
2024-03-01 22:38:46 +01:00
parent 7ebc470a7b
commit 32c5e8ae91
7 changed files with 507 additions and 66 deletions

View File

@@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
import 'package:custom_sliding_segmented_control/custom_sliding_segmented_control.dart';
import 'package:refilc/theme/colors/colors.dart';
class CustomSegmentedControl extends StatelessWidget {
final void Function(int)? onChanged;
final int value;
final List<Widget> children;
final int duration;
final bool showDivider;
final double height;
const CustomSegmentedControl({
super.key,
this.onChanged,
required this.value,
required this.children,
this.duration = 200,
this.showDivider = true,
this.height = 40,
});
@override
Widget build(BuildContext context) {
Map<int, Widget> finalChildren = {};
var i = 0;
for (var e in children) {
finalChildren.addAll({i: e});
i++;
}
return CustomSlidingSegmentedControl<int>(
initialValue: value,
children: finalChildren,
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondary.withOpacity(.069),
borderRadius: BorderRadius.circular(12.0),
),
thumbDecoration: BoxDecoration(
color: AppColors.of(context).highlight,
borderRadius: BorderRadius.circular(10.0),
// boxShadow: [
// BoxShadow(
// color: Colors.black.withOpacity(.3),
// blurRadius: 4.0,
// spreadRadius: 1.0,
// offset: const Offset(
// 0.0,
// 2.0,
// ),
// ),
// ],
),
duration: Duration(milliseconds: duration),
curve: Curves.easeInOutCubic,
onValueChanged: onChanged ?? (v) {},
isStretch: true,
innerPadding: const EdgeInsets.all(4.0),
isShowDivider: showDivider,
dividerSettings: DividerSettings(
indent: (height / 4) + 1,
endIndent: (height / 4) + 1,
// indent: 0,
// endIndent: 2,
// thickness: 2,
decoration: BoxDecoration(
color: AppColors.of(context).text.withOpacity(0.2),
),
),
height: height,
customSegmentSettings:
CustomSegmentSettings(hoverColor: Colors.transparent),
);
}
}

View File

@@ -102,6 +102,16 @@ extension SettingsLocalization on String {
"calendar_sync": "Calendar Sync",
"choose_account": "Choose Account",
"your_account": "Your Account",
"show_renamed": "Renamed teachers/subjects",
"show_teacher": "Teacher name in description",
"show_exams": "Show Exams (📝)",
"options": "Options",
"description": "Description",
"location": "Location",
"room_num_location": "Location of Room Number",
"choose_calendar": "Choose calendar",
'change_account': 'Change Account (Logout)',
"soon": "Soon",
},
"hu_hu": {
"personal_details": "Személyes információk",
@@ -202,6 +212,16 @@ extension SettingsLocalization on String {
"calendar_sync": "Naptár szinkronizálás",
"choose_account": "Válassz fiókot",
"your_account": "Fiókod",
"show_renamed": "Átnevezett tanárok/tantárgyak",
"show_teacher": "Tanár neve a leírásba",
"show_exams": "Számonkérések jelölése (📝)",
"options": "Beállítások",
"description": "Leírás",
"location": "Helyszín",
"room_num_location": "Teremszám helye",
"choose_calendar": "Válassz naptárat",
"change_account": "Fiók cseréje (Kijelentkezés)",
"soon": "Hamarosan",
},
"de_de": {
"personal_details": "Persönliche Angaben",
@@ -302,6 +322,16 @@ extension SettingsLocalization on String {
"calendar_sync": "Kalender-Synchronisation",
"choose_account": "Konto auswählen",
"your_account": "Ihr Konto",
"show_renamed": "Umbenannte Lehrer/Fächer",
"show_teacher": "Name des Lehrers in der Beschreibung",
"show_exams": "Prüfungen anzeigen (📝)",
"options": "Optionen",
"description": "Beschreibung",
"location": "Ort",
"room_num_location": "Standort der Zimmernummer",
"choose_calendar": "Kalender wählen",
"change_account": "Konto ändern (Abmeldung)",
"soon": "Bald",
},
};

View File

@@ -1,25 +1,20 @@
// ignore_for_file: use_build_context_synchronously
import 'package:collection/collection.dart';
import 'package:refilc/api/providers/user_provider.dart';
import 'package:refilc/models/linked_account.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/models/shared_theme.dart';
import 'package:refilc/providers/third_party_provider.dart';
import 'package:refilc/theme/colors/accent.dart';
import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc/theme/observer.dart';
import 'package:refilc_kreta_api/providers/share_provider.dart';
import 'package:refilc_mobile_ui/common/custom_snack_bar.dart';
import 'package:refilc_mobile_ui/common/dot.dart';
import 'package:refilc_mobile_ui/common/panel/panel_button.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart';
import 'package:refilc_mobile_ui/common/widgets/custom_segmented_control.dart';
import 'package:refilc_mobile_ui/screens/settings/settings_screen.i18n.dart';
import 'package:share_plus/share_plus.dart';
import 'package:flutter_any_logo/flutter_logo.dart';
class MenuCalendarSync extends StatelessWidget {
const MenuCalendarSync({
@@ -135,6 +130,13 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16.0),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 4.0,
spreadRadius: 0.01,
),
],
),
height: 64,
width: 64,
@@ -146,16 +148,31 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
const SizedBox(width: 10),
Icon(
Icons.sync_alt_outlined,
color:
AppColors.of(context).text.withOpacity(0.2),
color: AppColors.of(context).text.withOpacity(
thirdPartyProvider.linkedAccounts.isEmpty
? 0.2
: 0.5),
size: 20.0,
),
const SizedBox(width: 10),
Image.asset(
'assets/icons/ic_rounded.png',
width: 64,
height: 64,
)
Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(16.0),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
blurRadius: 4.0,
spreadRadius: 0.01,
),
],
),
child: Image.asset(
'assets/icons/ic_rounded.png',
width: 64,
height: 64,
),
),
],
),
),
@@ -228,7 +245,7 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
height: 24.0,
),
trailing: Text(
'Hamarosan'.i18n,
'soon'.i18n,
style: const TextStyle(
fontStyle: FontStyle.italic,
fontSize: 14.0),
@@ -306,53 +323,187 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
SplittedPanel(
title: Text('choose_calendar'.i18n),
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0),
cardPadding: EdgeInsets.zero,
isTransparent: true,
children: getCalendarList(),
),
const SizedBox(
height: 18.0,
),
SplittedPanel(
title: Text('room_num_location'.i18n),
padding: EdgeInsets.zero,
cardPadding: EdgeInsets.zero,
isTransparent: true,
children: [
PanelButton(
onPressed: null,
title: Text(
thirdPartyProvider
.linkedAccounts.first.username,
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(.95),
),
),
leading: Image.asset(
'assets/images/ext_logo/${thirdPartyProvider.linkedAccounts.first.type == AccountType.google ? "google" : "apple"}.png',
width: 24.0,
height: 24.0,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
bottom: Radius.circular(12),
),
),
PanelButton(
onPressed: () async {
await thirdPartyProvider.signOutAll();
setState(() {});
CustomSegmentedControl(
onChanged: (v) {
settingsProvider.update(
calSyncRoomLocation:
v == 0 ? 'location' : 'description');
},
title: Text(
'change_account'.i18n,
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(.95),
value: settingsProvider.calSyncRoomLocation ==
'location'
? 0
: 1,
height: 45,
children: [
Text(
'location'.i18n,
style: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 16.0,
),
),
),
trailing: Icon(
FeatherIcons.chevronRight,
size: 22.0,
color: AppColors.of(context)
.text
.withOpacity(0.95),
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
bottom: Radius.circular(12),
),
Text(
'description'.i18n,
style: const TextStyle(
fontWeight: FontWeight.w500,
fontSize: 16.0,
),
),
],
),
],
),
const SizedBox(
height: 18.0,
),
SplittedPanel(
title: Text('options'.i18n),
padding: EdgeInsets.zero,
cardPadding: EdgeInsets.zero,
isTransparent: true,
isSeparated: true,
children: [
SplittedPanel(
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0),
children: [
PanelButton(
padding: const EdgeInsets.only(
left: 14.0, right: 6.0),
onPressed: () async {
settingsProvider.update(
calSyncShowExams:
!settingsProvider.calSyncShowExams);
setState(() {});
},
title: Text(
"show_exams".i18n,
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(
settingsProvider.calSyncShowExams
? .95
: .25),
),
),
trailing: Switch(
onChanged: (v) async {
settingsProvider.update(
calSyncShowExams: v);
setState(() {});
},
value: settingsProvider.calSyncShowExams,
activeColor:
Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0),
children: [
PanelButton(
padding: const EdgeInsets.only(
left: 14.0, right: 6.0),
onPressed: () async {
settingsProvider.update(
calSyncShowTeacher: !settingsProvider
.calSyncShowTeacher);
setState(() {});
},
title: Text(
"show_teacher".i18n,
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(settingsProvider
.calSyncShowTeacher
? .95
: .25),
),
),
trailing: Switch(
onChanged: (v) async {
settingsProvider.update(
calSyncShowTeacher: v);
setState(() {});
},
value: settingsProvider.calSyncShowTeacher,
activeColor:
Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
SplittedPanel(
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.all(4.0),
children: [
PanelButton(
padding: const EdgeInsets.only(
left: 14.0, right: 6.0),
onPressed: () async {
settingsProvider.update(
calSyncRenamed:
!settingsProvider.calSyncRenamed);
setState(() {});
},
title: Text(
"show_renamed".i18n,
style: TextStyle(
color: AppColors.of(context)
.text
.withOpacity(
settingsProvider.calSyncRenamed
? .95
: .25),
),
),
trailing: Switch(
onChanged: (v) async {
settingsProvider.update(
calSyncRenamed: v);
setState(() {});
},
value: settingsProvider.calSyncRenamed,
activeColor:
Theme.of(context).colorScheme.secondary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12.0),
bottom: Radius.circular(12.0),
),
),
],
),
],
),
@@ -366,4 +517,86 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
),
);
}
List<Widget> getCalendarList() {
// List<Widget> widgets = thirdPartyProvider.googleCalendars
// .map(
// (e) => Container(
// margin: const EdgeInsets.only(bottom: 3.0),
// decoration: BoxDecoration(
// border: Border.all(
// color: Theme.of(context).colorScheme.primary.withOpacity(.25),
// width: 1.0,
// ),
// borderRadius: BorderRadius.circular(12.0),
// ),
// child: PanelButton(
// onPressed: () async {
// print((e.backgroundColor ?? '#000000').replaceAll('#', '0x'));
// setState(() {});
// },
// title: Text(
// e.summary ?? 'no_title'.i18n,
// style: TextStyle(
// color: AppColors.of(context).text.withOpacity(.95),
// ),
// ),
// leading: Dot(
// color: colorFromHex(
// e.backgroundColor ?? '#000',
// ) ??
// Colors.black,
// ),
// borderRadius: const BorderRadius.vertical(
// top: Radius.circular(12),
// bottom: Radius.circular(12),
// ),
// ),
// ),
// )
// .toList();
List<Widget> widgets = [];
widgets.add(
Container(
margin: const EdgeInsets.only(bottom: 3.0),
decoration: BoxDecoration(
// border: Border.all(
// color: Theme.of(context).colorScheme.primary.withOpacity(.25),
// width: 1.0,
// ),
color: AppColors.of(context).highlight,
borderRadius: BorderRadius.circular(16.0),
),
child: PanelButton(
onPressed: null,
// onPressed: () async {
// // thirdPartyProvider.pushTimetable(context, timetable);
// setState(() {});
// },
title: Text(
'reFilc - Órarend',
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.95),
),
),
// leading: Icon(
// FeatherIcons.plus,
// size: 20.0,
// color: AppColors.of(context).text.withOpacity(0.75),
// ),
leading: Dot(
color: Theme.of(context).colorScheme.primary,
),
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
bottom: Radius.circular(12),
),
),
),
);
return widgets;
}
}

View File

@@ -66,6 +66,7 @@ dependencies:
google_fonts: ^6.1.0
flutter_stripe: ^10.0.0
flutter_any_logo: ^1.1.1
custom_sliding_segmented_control: ^1.8.1
dev_dependencies:
flutter_lints: ^3.0.1