forked from firka/student-legacy
finished calendar sync settings part
This commit is contained in:
parent
7ebc470a7b
commit
32c5e8ae91
@ -45,6 +45,10 @@ const settingsDB = DatabaseStruct("settings", {
|
|||||||
"show_breaks": int,
|
"show_breaks": int,
|
||||||
"font_family": String,
|
"font_family": String,
|
||||||
"plus_session_id": String,
|
"plus_session_id": String,
|
||||||
|
"cal_sync_room_location": String,
|
||||||
|
"cal_sync_show_exams": int,
|
||||||
|
"cal_sync_show_teacher": int,
|
||||||
|
"cal_sync_renamed": int,
|
||||||
});
|
});
|
||||||
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
|
// DON'T FORGET TO UPDATE DEFAULT VALUES IN `initDB` MIGRATION OR ELSE PARENTS WILL COMPLAIN ABOUT THEIR CHILDREN MISSING
|
||||||
// YOU'VE BEEN WARNED!!!
|
// YOU'VE BEEN WARNED!!!
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:refilc/api/providers/database_provider.dart';
|
import 'package:refilc/api/providers/database_provider.dart';
|
||||||
import 'package:refilc/models/config.dart';
|
import 'package:refilc/models/config.dart';
|
||||||
import 'package:refilc/models/icon_pack.dart';
|
import 'package:refilc/models/icon_pack.dart';
|
||||||
@ -92,6 +93,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
bool _showBreaks;
|
bool _showBreaks;
|
||||||
String _fontFamily;
|
String _fontFamily;
|
||||||
String _plusSessionId;
|
String _plusSessionId;
|
||||||
|
String _calSyncRoomLocation;
|
||||||
|
bool _calSyncShowExams;
|
||||||
|
bool _calSyncShowTeacher;
|
||||||
|
bool _calSyncRenamed;
|
||||||
|
|
||||||
SettingsProvider({
|
SettingsProvider({
|
||||||
DatabaseProvider? database,
|
DatabaseProvider? database,
|
||||||
@ -150,6 +155,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
required String pinSetExtras,
|
required String pinSetExtras,
|
||||||
required String fontFamily,
|
required String fontFamily,
|
||||||
required String plusSessionId,
|
required String plusSessionId,
|
||||||
|
required String calSyncRoomLocation,
|
||||||
|
required bool calSyncShowExams,
|
||||||
|
required bool calSyncShowTeacher,
|
||||||
|
required bool calSyncRenamed,
|
||||||
}) : _database = database,
|
}) : _database = database,
|
||||||
_language = language,
|
_language = language,
|
||||||
_startPage = startPage,
|
_startPage = startPage,
|
||||||
@ -205,7 +214,11 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
_pinSetNotify = pinSetNotify,
|
_pinSetNotify = pinSetNotify,
|
||||||
_pinSetExtras = pinSetExtras,
|
_pinSetExtras = pinSetExtras,
|
||||||
_fontFamily = fontFamily,
|
_fontFamily = fontFamily,
|
||||||
_plusSessionId = plusSessionId;
|
_plusSessionId = plusSessionId,
|
||||||
|
_calSyncRoomLocation = calSyncRoomLocation,
|
||||||
|
_calSyncShowExams = calSyncShowExams,
|
||||||
|
_calSyncShowTeacher = calSyncShowTeacher,
|
||||||
|
_calSyncRenamed = calSyncRenamed;
|
||||||
|
|
||||||
factory SettingsProvider.fromMap(Map map,
|
factory SettingsProvider.fromMap(Map map,
|
||||||
{required DatabaseProvider database}) {
|
{required DatabaseProvider database}) {
|
||||||
@ -281,6 +294,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
pinSetExtras: map['extras_s_pin'],
|
pinSetExtras: map['extras_s_pin'],
|
||||||
fontFamily: map['font_family'],
|
fontFamily: map['font_family'],
|
||||||
plusSessionId: map['plus_session_id'],
|
plusSessionId: map['plus_session_id'],
|
||||||
|
calSyncRoomLocation: map['cal_sync_room_location'],
|
||||||
|
calSyncShowExams: map['cal_sync_show_exams'] == 1,
|
||||||
|
calSyncShowTeacher: map['cal_sync_show_teacher'] == 1,
|
||||||
|
calSyncRenamed: map['cal_sync_renamed'] == 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,6 +361,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
"extras_s_pin": _pinSetExtras,
|
"extras_s_pin": _pinSetExtras,
|
||||||
"font_family": _fontFamily,
|
"font_family": _fontFamily,
|
||||||
"plus_session_id": _plusSessionId,
|
"plus_session_id": _plusSessionId,
|
||||||
|
"cal_sync_room_location": _calSyncRoomLocation,
|
||||||
|
"cal_sync_show_exams": _calSyncShowExams ? 1 : 0,
|
||||||
|
"cal_sync_show_teacher": _calSyncShowTeacher ? 1 : 0,
|
||||||
|
"cal_sync_renamed": _calSyncRenamed ? 1 : 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,6 +432,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
pinSetExtras: '',
|
pinSetExtras: '',
|
||||||
fontFamily: '',
|
fontFamily: '',
|
||||||
plusSessionId: '',
|
plusSessionId: '',
|
||||||
|
calSyncRoomLocation: 'location',
|
||||||
|
calSyncShowExams: true,
|
||||||
|
calSyncShowTeacher: true,
|
||||||
|
calSyncRenamed: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -469,6 +494,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
bool get showBreaks => _showBreaks;
|
bool get showBreaks => _showBreaks;
|
||||||
String get fontFamily => _fontFamily;
|
String get fontFamily => _fontFamily;
|
||||||
String get plusSessionId => _plusSessionId;
|
String get plusSessionId => _plusSessionId;
|
||||||
|
String get calSyncRoomLocation => _calSyncRoomLocation;
|
||||||
|
bool get calSyncShowExams => _calSyncShowExams;
|
||||||
|
bool get calSyncShowTeacher => _calSyncShowTeacher;
|
||||||
|
bool get calSyncRenamed => _calSyncRenamed;
|
||||||
|
|
||||||
Future<void> update({
|
Future<void> update({
|
||||||
bool store = true,
|
bool store = true,
|
||||||
@ -523,6 +552,10 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
bool? showBreaks,
|
bool? showBreaks,
|
||||||
String? fontFamily,
|
String? fontFamily,
|
||||||
String? plusSessionId,
|
String? plusSessionId,
|
||||||
|
String? calSyncRoomLocation,
|
||||||
|
bool? calSyncShowExams,
|
||||||
|
bool? calSyncShowTeacher,
|
||||||
|
bool? calSyncRenamed,
|
||||||
}) async {
|
}) async {
|
||||||
if (language != null && language != _language) _language = language;
|
if (language != null && language != _language) _language = language;
|
||||||
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
||||||
@ -673,8 +706,27 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
if (plusSessionId != null && plusSessionId != _plusSessionId) {
|
if (plusSessionId != null && plusSessionId != _plusSessionId) {
|
||||||
_plusSessionId = plusSessionId;
|
_plusSessionId = plusSessionId;
|
||||||
}
|
}
|
||||||
|
if (calSyncRoomLocation != null &&
|
||||||
|
calSyncRoomLocation != _calSyncRoomLocation) {
|
||||||
|
_calSyncRoomLocation = calSyncRoomLocation;
|
||||||
|
}
|
||||||
|
if (calSyncShowExams != null && calSyncShowExams != _calSyncShowExams) {
|
||||||
|
_calSyncShowExams = calSyncShowExams;
|
||||||
|
}
|
||||||
|
if (calSyncShowTeacher != null &&
|
||||||
|
calSyncShowTeacher != _calSyncShowTeacher) {
|
||||||
|
_calSyncShowTeacher = calSyncShowTeacher;
|
||||||
|
}
|
||||||
|
if (calSyncRenamed != null && calSyncRenamed != _calSyncRenamed) {
|
||||||
|
_calSyncRenamed = calSyncRenamed;
|
||||||
|
}
|
||||||
// store or not
|
// store or not
|
||||||
if (store) await _database?.store.storeSettings(this);
|
if (store) await _database?.store.storeSettings(this);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exportJson() {
|
||||||
|
String sets = json.encode(toMap());
|
||||||
|
Clipboard.setData(ClipboardData(text: sets));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:refilc/api/providers/database_provider.dart';
|
import 'package:refilc/api/providers/database_provider.dart';
|
||||||
import 'package:refilc/api/providers/user_provider.dart';
|
import 'package:refilc/api/providers/user_provider.dart';
|
||||||
import 'package:refilc/models/linked_account.dart';
|
import 'package:refilc/models/linked_account.dart';
|
||||||
|
import 'package:refilc/models/user.dart';
|
||||||
import 'package:refilc_kreta_api/controllers/timetable_controller.dart';
|
import 'package:refilc_kreta_api/controllers/timetable_controller.dart';
|
||||||
import 'package:refilc_kreta_api/models/lesson.dart';
|
import 'package:refilc_kreta_api/models/lesson.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@ -14,7 +15,7 @@ class ThirdPartyProvider with ChangeNotifier {
|
|||||||
late List<LinkedAccount> _linkedAccounts;
|
late List<LinkedAccount> _linkedAccounts;
|
||||||
// google specific
|
// google specific
|
||||||
late List<Event>? _googleEvents;
|
late List<Event>? _googleEvents;
|
||||||
late List<Calendar>? _googleCalendars;
|
late List<CalendarListEntry> _googleCalendars;
|
||||||
|
|
||||||
late BuildContext _context;
|
late BuildContext _context;
|
||||||
|
|
||||||
@ -27,16 +28,18 @@ class ThirdPartyProvider with ChangeNotifier {
|
|||||||
List<LinkedAccount> get linkedAccounts => _linkedAccounts;
|
List<LinkedAccount> get linkedAccounts => _linkedAccounts;
|
||||||
|
|
||||||
List<Event> get googleEvents => _googleEvents ?? [];
|
List<Event> get googleEvents => _googleEvents ?? [];
|
||||||
List<Calendar> get googleCalendars => _googleCalendars ?? [];
|
List<CalendarListEntry> get googleCalendars => _googleCalendars;
|
||||||
|
|
||||||
ThirdPartyProvider({
|
ThirdPartyProvider({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
List<LinkedAccount>? initialLinkedAccounts,
|
List<LinkedAccount>? initialLinkedAccounts,
|
||||||
}) {
|
}) {
|
||||||
_context = context;
|
_context = context;
|
||||||
_linkedAccounts = initialLinkedAccounts ?? [];
|
_linkedAccounts = List.castFrom(initialLinkedAccounts ?? []);
|
||||||
|
_googleCalendars = [];
|
||||||
|
|
||||||
if (_linkedAccounts.isEmpty) restore();
|
if (_linkedAccounts.isEmpty) restore();
|
||||||
|
if (_googleCalendars.isEmpty) fetchGoogle();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> restore() async {
|
Future<void> restore() async {
|
||||||
@ -49,23 +52,47 @@ class ThirdPartyProvider with ChangeNotifier {
|
|||||||
.userQuery
|
.userQuery
|
||||||
.getLinkedAccounts(userId: userId);
|
.getLinkedAccounts(userId: userId);
|
||||||
_linkedAccounts = dbLinkedAccounts;
|
_linkedAccounts = dbLinkedAccounts;
|
||||||
|
|
||||||
|
// if (res == null) {
|
||||||
|
// throw 'Google sign in failed, some data will be unavailable.';
|
||||||
|
// }
|
||||||
|
|
||||||
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> store(List<LinkedAccount> accounts) async {
|
||||||
|
User? user = Provider.of<UserProvider>(_context, listen: false).user;
|
||||||
|
if (user == null) throw "Cannot store Linked Accounts for User null";
|
||||||
|
String userId = user.id;
|
||||||
|
|
||||||
|
await Provider.of<DatabaseProvider>(_context, listen: false)
|
||||||
|
.userStore
|
||||||
|
.storeLinkedAccounts(accounts, userId: userId);
|
||||||
|
_linkedAccounts = accounts;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void fetch() async {}
|
void fetch() async {}
|
||||||
|
|
||||||
Future<GoogleSignInAccount?> googleSignIn() async {
|
Future<GoogleSignInAccount?> googleSignIn() async {
|
||||||
|
// signOutAll();
|
||||||
|
|
||||||
if (!await _googleSignIn.isSignedIn()) {
|
if (!await _googleSignIn.isSignedIn()) {
|
||||||
GoogleSignInAccount? account = await _googleSignIn.signIn();
|
GoogleSignInAccount? account = await _googleSignIn.signIn();
|
||||||
|
|
||||||
|
if (account == null) return null;
|
||||||
|
|
||||||
LinkedAccount linked = LinkedAccount.fromJson({
|
LinkedAccount linked = LinkedAccount.fromJson({
|
||||||
'type': 'google',
|
'type': 'google',
|
||||||
'username': account?.email ?? '',
|
'username': account.email,
|
||||||
'display_name': account?.displayName ?? '',
|
'display_name': account.displayName ?? '',
|
||||||
'id': account?.id ?? ''
|
'id': account.id,
|
||||||
});
|
});
|
||||||
_linkedAccounts.add(linked);
|
_linkedAccounts.add(linked);
|
||||||
|
|
||||||
|
store(_linkedAccounts);
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -99,6 +126,24 @@ class ThirdPartyProvider with ChangeNotifier {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
Future<void> fetchGoogle() async {
|
||||||
|
await _googleSignIn.signInSilently();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var httpClient = (await _googleSignIn.authenticatedClient())!;
|
||||||
|
var calendarApi = CalendarApi(httpClient);
|
||||||
|
|
||||||
|
_googleCalendars = (await calendarApi.calendarList.list()).items ?? [];
|
||||||
|
|
||||||
|
print(_googleCalendars);
|
||||||
|
|
||||||
|
notifyListeners();
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
// await _googleSignIn.signOut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<Event?> pushEvent({
|
Future<Event?> pushEvent({
|
||||||
required String title,
|
required String title,
|
||||||
required String calendarId,
|
required String calendarId,
|
||||||
|
@ -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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -102,6 +102,16 @@ extension SettingsLocalization on String {
|
|||||||
"calendar_sync": "Calendar Sync",
|
"calendar_sync": "Calendar Sync",
|
||||||
"choose_account": "Choose Account",
|
"choose_account": "Choose Account",
|
||||||
"your_account": "Your 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": {
|
"hu_hu": {
|
||||||
"personal_details": "Személyes információk",
|
"personal_details": "Személyes információk",
|
||||||
@ -202,6 +212,16 @@ extension SettingsLocalization on String {
|
|||||||
"calendar_sync": "Naptár szinkronizálás",
|
"calendar_sync": "Naptár szinkronizálás",
|
||||||
"choose_account": "Válassz fiókot",
|
"choose_account": "Válassz fiókot",
|
||||||
"your_account": "Fiókod",
|
"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": {
|
"de_de": {
|
||||||
"personal_details": "Persönliche Angaben",
|
"personal_details": "Persönliche Angaben",
|
||||||
@ -302,6 +322,16 @@ extension SettingsLocalization on String {
|
|||||||
"calendar_sync": "Kalender-Synchronisation",
|
"calendar_sync": "Kalender-Synchronisation",
|
||||||
"choose_account": "Konto auswählen",
|
"choose_account": "Konto auswählen",
|
||||||
"your_account": "Ihr Konto",
|
"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",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,25 +1,20 @@
|
|||||||
// ignore_for_file: use_build_context_synchronously
|
// ignore_for_file: use_build_context_synchronously
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
|
||||||
import 'package:refilc/api/providers/user_provider.dart';
|
import 'package:refilc/api/providers/user_provider.dart';
|
||||||
import 'package:refilc/models/linked_account.dart';
|
import 'package:refilc/models/linked_account.dart';
|
||||||
import 'package:refilc/models/settings.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/providers/third_party_provider.dart';
|
||||||
import 'package:refilc/theme/colors/accent.dart';
|
|
||||||
import 'package:refilc/theme/colors/colors.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_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/panel/panel_button.dart';
|
||||||
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
|
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
import 'package:flutter_feather_icons/flutter_feather_icons.dart';
|
||||||
import 'package:provider/provider.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: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 {
|
class MenuCalendarSync extends StatelessWidget {
|
||||||
const MenuCalendarSync({
|
const MenuCalendarSync({
|
||||||
@ -135,6 +130,13 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(16.0),
|
borderRadius: BorderRadius.circular(16.0),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.2),
|
||||||
|
blurRadius: 4.0,
|
||||||
|
spreadRadius: 0.01,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
height: 64,
|
height: 64,
|
||||||
width: 64,
|
width: 64,
|
||||||
@ -146,16 +148,31 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Icon(
|
Icon(
|
||||||
Icons.sync_alt_outlined,
|
Icons.sync_alt_outlined,
|
||||||
color:
|
color: AppColors.of(context).text.withOpacity(
|
||||||
AppColors.of(context).text.withOpacity(0.2),
|
thirdPartyProvider.linkedAccounts.isEmpty
|
||||||
|
? 0.2
|
||||||
|
: 0.5),
|
||||||
size: 20.0,
|
size: 20.0,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Image.asset(
|
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',
|
'assets/icons/ic_rounded.png',
|
||||||
width: 64,
|
width: 64,
|
||||||
height: 64,
|
height: 64,
|
||||||
)
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -228,7 +245,7 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
|
|||||||
height: 24.0,
|
height: 24.0,
|
||||||
),
|
),
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
'Hamarosan'.i18n,
|
'soon'.i18n,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontStyle: FontStyle.italic,
|
fontStyle: FontStyle.italic,
|
||||||
fontSize: 14.0),
|
fontSize: 14.0),
|
||||||
@ -305,57 +322,191 @@ class CalendarSyncScreenState extends State<CalendarSyncScreen>
|
|||||||
),
|
),
|
||||||
SplittedPanel(
|
SplittedPanel(
|
||||||
title: Text('choose_calendar'.i18n),
|
title: Text('choose_calendar'.i18n),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
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: [
|
||||||
|
CustomSegmentedControl(
|
||||||
|
onChanged: (v) {
|
||||||
|
settingsProvider.update(
|
||||||
|
calSyncRoomLocation:
|
||||||
|
v == 0 ? 'location' : 'description');
|
||||||
|
},
|
||||||
|
value: settingsProvider.calSyncRoomLocation ==
|
||||||
|
'location'
|
||||||
|
? 0
|
||||||
|
: 1,
|
||||||
|
height: 45,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'location'.i18n,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
fontSize: 16.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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,
|
padding: EdgeInsets.zero,
|
||||||
cardPadding: const EdgeInsets.all(4.0),
|
cardPadding: const EdgeInsets.all(4.0),
|
||||||
children: [
|
children: [
|
||||||
PanelButton(
|
PanelButton(
|
||||||
onPressed: null,
|
padding: const EdgeInsets.only(
|
||||||
title: Text(
|
left: 14.0, right: 6.0),
|
||||||
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 {
|
onPressed: () async {
|
||||||
await thirdPartyProvider.signOutAll();
|
settingsProvider.update(
|
||||||
|
calSyncShowExams:
|
||||||
|
!settingsProvider.calSyncShowExams);
|
||||||
|
|
||||||
setState(() {});
|
setState(() {});
|
||||||
},
|
},
|
||||||
title: Text(
|
title: Text(
|
||||||
'change_account'.i18n,
|
"show_exams".i18n,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: AppColors.of(context)
|
color: AppColors.of(context)
|
||||||
.text
|
.text
|
||||||
.withOpacity(.95),
|
.withOpacity(
|
||||||
|
settingsProvider.calSyncShowExams
|
||||||
|
? .95
|
||||||
|
: .25),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Switch(
|
||||||
FeatherIcons.chevronRight,
|
onChanged: (v) async {
|
||||||
size: 22.0,
|
settingsProvider.update(
|
||||||
color: AppColors.of(context)
|
calSyncShowExams: v);
|
||||||
.text
|
|
||||||
.withOpacity(0.95),
|
setState(() {});
|
||||||
|
},
|
||||||
|
value: settingsProvider.calSyncShowExams,
|
||||||
|
activeColor:
|
||||||
|
Theme.of(context).colorScheme.secondary,
|
||||||
),
|
),
|
||||||
borderRadius: const BorderRadius.vertical(
|
borderRadius: const BorderRadius.vertical(
|
||||||
top: Radius.circular(12),
|
top: Radius.circular(12.0),
|
||||||
bottom: Radius.circular(12),
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ dependencies:
|
|||||||
google_fonts: ^6.1.0
|
google_fonts: ^6.1.0
|
||||||
flutter_stripe: ^10.0.0
|
flutter_stripe: ^10.0.0
|
||||||
flutter_any_logo: ^1.1.1
|
flutter_any_logo: ^1.1.1
|
||||||
|
custom_sliding_segmented_control: ^1.8.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_lints: ^3.0.1
|
flutter_lints: ^3.0.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user