commit
cd8ab8bfdb
@ -40,6 +40,11 @@ class FilcAPI {
|
||||
static const allThemes = "$themeGet/all";
|
||||
static const themeByID = "$themeGet/";
|
||||
|
||||
static const gradeColorsShare = "$baseUrl/v2/shared/grade-colors/add";
|
||||
static const gradeColorsGet = "$baseUrl/v2/shared/grade-colors/get";
|
||||
static const allGradeColors = "$gradeColorsGet/all";
|
||||
static const gradeColorsByID = "$gradeColorsGet/";
|
||||
|
||||
static Future<bool> checkConnectivity() async =>
|
||||
(await Connectivity().checkConnectivity()) != ConnectivityResult.none;
|
||||
|
||||
@ -209,6 +214,9 @@ class FilcAPI {
|
||||
theme.json['panels_color'] = theme.panelsColor.value.toString();
|
||||
theme.json['accent_color'] = theme.accentColor.value.toString();
|
||||
|
||||
// set linked grade colors
|
||||
theme.json['grade_colors_id'] = theme.gradeColors.id;
|
||||
|
||||
http.Response res = await http.post(
|
||||
Uri.parse(themeShare),
|
||||
body: theme.json,
|
||||
@ -235,7 +243,49 @@ class FilcAPI {
|
||||
throw "HTTP ${res.statusCode}: ${res.body}";
|
||||
}
|
||||
} on Exception catch (error, stacktrace) {
|
||||
log("ERROR: FilcAPI.addSharedTheme: $error $stacktrace");
|
||||
log("ERROR: FilcAPI.getSharedTheme: $error $stacktrace");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<void> addSharedGradeColors(
|
||||
SharedGradeColors gradeColors) async {
|
||||
try {
|
||||
gradeColors.json.remove('json');
|
||||
gradeColors.json['is_public'] = gradeColors.isPublic.toString();
|
||||
gradeColors.json['five_color'] = gradeColors.fiveColor.value.toString();
|
||||
gradeColors.json['four_color'] = gradeColors.fourColor.value.toString();
|
||||
gradeColors.json['three_color'] = gradeColors.threeColor.value.toString();
|
||||
gradeColors.json['two_color'] = gradeColors.twoColor.value.toString();
|
||||
gradeColors.json['one_color'] = gradeColors.oneColor.value.toString();
|
||||
|
||||
http.Response res = await http.post(
|
||||
Uri.parse(gradeColorsShare),
|
||||
body: gradeColors.json,
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
);
|
||||
|
||||
if (res.statusCode != 201) {
|
||||
throw "HTTP ${res.statusCode}: ${res.body}";
|
||||
}
|
||||
|
||||
log('Shared grade colors successfully with ID: ${gradeColors.id}');
|
||||
} on Exception catch (error, stacktrace) {
|
||||
log("ERROR: FilcAPI.addSharedGradeColors: $error $stacktrace");
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map?> getSharedGradeColors(String id) async {
|
||||
try {
|
||||
http.Response res = await http.get(Uri.parse(gradeColorsByID + id));
|
||||
|
||||
if (res.statusCode == 200) {
|
||||
return (jsonDecode(res.body) as Map);
|
||||
} else {
|
||||
throw "HTTP ${res.statusCode}: ${res.body}";
|
||||
}
|
||||
} on Exception catch (error, stacktrace) {
|
||||
log("ERROR: FilcAPI.getSharedGradeColors: $error $stacktrace");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ class SharedTheme {
|
||||
Color backgroundColor;
|
||||
Color panelsColor;
|
||||
Color accentColor;
|
||||
SharedGradeColors gradeColors;
|
||||
|
||||
SharedTheme({
|
||||
required this.json,
|
||||
@ -17,9 +18,10 @@ class SharedTheme {
|
||||
required this.backgroundColor,
|
||||
required this.panelsColor,
|
||||
required this.accentColor,
|
||||
required this.gradeColors,
|
||||
});
|
||||
|
||||
factory SharedTheme.fromJson(Map json) {
|
||||
factory SharedTheme.fromJson(Map json, SharedGradeColors gradeColors) {
|
||||
return SharedTheme(
|
||||
json: json,
|
||||
id: json['public_id'],
|
||||
@ -28,6 +30,45 @@ class SharedTheme {
|
||||
backgroundColor: Color(json['background_color']),
|
||||
panelsColor: Color(json['panels_color']),
|
||||
accentColor: Color(json['accent_color']),
|
||||
gradeColors: gradeColors,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SharedGradeColors {
|
||||
Map json;
|
||||
String id;
|
||||
bool isPublic;
|
||||
String nickname;
|
||||
Color fiveColor;
|
||||
Color fourColor;
|
||||
Color threeColor;
|
||||
Color twoColor;
|
||||
Color oneColor;
|
||||
|
||||
SharedGradeColors({
|
||||
required this.json,
|
||||
required this.id,
|
||||
this.isPublic = false,
|
||||
this.nickname = 'Anonymous',
|
||||
required this.fiveColor,
|
||||
required this.fourColor,
|
||||
required this.threeColor,
|
||||
required this.twoColor,
|
||||
required this.oneColor,
|
||||
});
|
||||
|
||||
factory SharedGradeColors.fromJson(Map json) {
|
||||
return SharedGradeColors(
|
||||
json: json,
|
||||
id: json['public_id'],
|
||||
isPublic: json['is_public'] ?? false,
|
||||
nickname: json['nickname'] ?? 'Anonymous',
|
||||
fiveColor: Color(json['five_color']),
|
||||
fourColor: Color(json['four_color']),
|
||||
threeColor: Color(json['three_color']),
|
||||
twoColor: Color(json['two_color']),
|
||||
oneColor: Color(json['one_color']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:filcnaplo_kreta_api/client/api.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/school.dart';
|
||||
import 'package:filcnaplo_kreta_api/models/student.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
@ -43,7 +44,16 @@ class User {
|
||||
username: map["username"],
|
||||
password: map["password"],
|
||||
name: map["name"].trim(),
|
||||
student: Student.fromJson(jsonDecode(map["student"])),
|
||||
student: map["student"] != 'null'
|
||||
? Student.fromJson(jsonDecode(map["student"]))
|
||||
: Student(
|
||||
id: const Uuid().v4(),
|
||||
name: 'Ismeretlen Diák',
|
||||
school: School(instituteCode: '', name: '', city: ''),
|
||||
birth: DateTime.now(),
|
||||
yearId: '1',
|
||||
parents: [],
|
||||
),
|
||||
role: Role.values[map["role"] ?? 0],
|
||||
nickname: map["nickname"] ?? "",
|
||||
picture: map["picture"] ?? "",
|
||||
|
@ -101,6 +101,7 @@ Future<List<DateWidget>> getFilterWidgets(FilterType activeData,
|
||||
gradeProvider.grades, gradeProvider.lastSeenDate);
|
||||
if (settingsProvider.gradeOpeningFun) {
|
||||
items.addAll(
|
||||
// ignore: use_build_context_synchronously
|
||||
await getFilterWidgets(FilterType.newGrades, context: context));
|
||||
}
|
||||
break;
|
||||
|
@ -3,7 +3,7 @@ description: "Nem hivatalos e-napló alkalmazás az e-Kréta rendszerhez"
|
||||
homepage: https://refilc.hu
|
||||
publish_to: "none"
|
||||
|
||||
version: 4.2.5+225
|
||||
version: 4.3.0+226
|
||||
|
||||
environment:
|
||||
sdk: ">=2.17.0 <3.0.0"
|
||||
|
@ -7,7 +7,7 @@ import 'package:filcnaplo/api/client.dart';
|
||||
import 'package:filcnaplo/api/login.dart';
|
||||
import 'package:filcnaplo_mobile_ui/screens/login/login_button.dart';
|
||||
import 'package:filcnaplo_mobile_ui/screens/login/login_input.dart';
|
||||
import 'package:filcnaplo_desktop_ui/screens/login/school_input/school_input.dart';
|
||||
// import 'package:filcnaplo_desktop_ui/screens/login/school_input/school_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_acrylic/flutter_acrylic.dart';
|
||||
@ -36,8 +36,8 @@ class LoginScreen extends StatefulWidget {
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
final usernameController = TextEditingController();
|
||||
final passwordController = TextEditingController();
|
||||
final schoolController = SchoolInputController();
|
||||
final _scrollController = ScrollController();
|
||||
// final schoolController = SchoolInputController();
|
||||
// final _scrollController = ScrollController();
|
||||
|
||||
LoginState _loginState = LoginState.normal;
|
||||
bool showBack = false;
|
||||
@ -57,9 +57,9 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
|
||||
FilcAPI.getSchools().then((schools) {
|
||||
if (schools != null) {
|
||||
schoolController.update(() {
|
||||
schoolController.schools = schools;
|
||||
});
|
||||
// schoolController.update(() {
|
||||
// schoolController.schools = schools;
|
||||
// });
|
||||
} else {
|
||||
ElegantNotification.error(
|
||||
background: Colors.white,
|
||||
@ -238,10 +238,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
SchoolInput(
|
||||
scroll: _scrollController,
|
||||
controller: schoolController,
|
||||
),
|
||||
// SchoolInput(
|
||||
// scroll: _scrollController,
|
||||
// controller: schoolController,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -320,8 +320,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
String password = passwordController.text;
|
||||
|
||||
if (username == "" ||
|
||||
password == "" ||
|
||||
schoolController.selectedSchool == null) {
|
||||
password ==
|
||||
"" /*||
|
||||
schoolController.selectedSchool == null*/
|
||||
) {
|
||||
return setState(() => _loginState = LoginState.missingFields);
|
||||
}
|
||||
|
||||
@ -330,7 +332,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
loginAPI(
|
||||
username: username,
|
||||
password: password,
|
||||
instituteCode: schoolController.selectedSchool!.instituteCode,
|
||||
instituteCode: 'shit',
|
||||
// instituteCode: schoolController.selectedSchool!.instituteCode,
|
||||
context: context,
|
||||
onLogin: (user) {
|
||||
ElegantNotification.success(
|
||||
|
@ -648,8 +648,8 @@ class _LiveActivityColorSettingState extends State<LiveActivityColorSetting> {
|
||||
setState(() {
|
||||
currentColor = k as Color;
|
||||
settings.update(
|
||||
liveActivityColor: currentColor.withAlpha(255));
|
||||
Navigator.of(context).maybePop();
|
||||
liveActivityColor: currentColor.withAlpha(255));
|
||||
Navigator.of(context).maybePop();
|
||||
});
|
||||
},
|
||||
elevation: 0,
|
||||
|
@ -17,8 +17,12 @@ class ShareProvider extends ChangeNotifier {
|
||||
// Future<void> shareTheme({required SharedTheme theme}) async {
|
||||
|
||||
// }
|
||||
|
||||
// themes
|
||||
Future<SharedTheme> shareCurrentTheme(BuildContext context,
|
||||
{bool isPublic = false, bool shareNick = true}) async {
|
||||
{bool isPublic = false,
|
||||
bool shareNick = true,
|
||||
required SharedGradeColors gradeColors}) async {
|
||||
final SettingsProvider settings =
|
||||
Provider.of<SettingsProvider>(context, listen: false);
|
||||
|
||||
@ -38,7 +42,7 @@ class ShareProvider extends ChangeNotifier {
|
||||
const Color(0xFF3D7BF4).value,
|
||||
};
|
||||
|
||||
SharedTheme theme = SharedTheme.fromJson(themeJson);
|
||||
SharedTheme theme = SharedTheme.fromJson(themeJson, gradeColors);
|
||||
FilcAPI.addSharedTheme(theme);
|
||||
|
||||
return theme;
|
||||
@ -49,8 +53,53 @@ class ShareProvider extends ChangeNotifier {
|
||||
Map? themeJson = await FilcAPI.getSharedTheme(id);
|
||||
|
||||
if (themeJson != null) {
|
||||
SharedTheme theme = SharedTheme.fromJson(themeJson);
|
||||
return theme;
|
||||
Map? gradeColorsJson =
|
||||
await FilcAPI.getSharedGradeColors(themeJson['grade_colors_id']);
|
||||
|
||||
if (gradeColorsJson != null) {
|
||||
SharedTheme theme = SharedTheme.fromJson(
|
||||
themeJson, SharedGradeColors.fromJson(gradeColorsJson));
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// grade colors
|
||||
Future<SharedGradeColors> shareCurrentGradeColors(
|
||||
BuildContext context, {
|
||||
bool isPublic = false,
|
||||
bool shareNick = true,
|
||||
}) async {
|
||||
final SettingsProvider settings =
|
||||
Provider.of<SettingsProvider>(context, listen: false);
|
||||
|
||||
Map gradeColorsJson = {
|
||||
'public_id': const Uuid().v4(),
|
||||
'is_public': isPublic,
|
||||
'nickname': shareNick ? _user.nickname : 'Anonymous',
|
||||
'five_color': settings.gradeColors[4].value,
|
||||
'four_color': settings.gradeColors[3].value,
|
||||
'three_color': settings.gradeColors[2].value,
|
||||
'two_color': settings.gradeColors[1].value,
|
||||
'one_color': settings.gradeColors[0].value,
|
||||
};
|
||||
|
||||
SharedGradeColors gradeColors = SharedGradeColors.fromJson(gradeColorsJson);
|
||||
FilcAPI.addSharedGradeColors(gradeColors);
|
||||
|
||||
return gradeColors;
|
||||
}
|
||||
|
||||
Future<SharedGradeColors?> getGradeColorsById(BuildContext context,
|
||||
{required String id}) async {
|
||||
Map? gradeColorsJson = await FilcAPI.getSharedGradeColors(id);
|
||||
|
||||
if (gradeColorsJson != null) {
|
||||
SharedGradeColors gradeColors =
|
||||
SharedGradeColors.fromJson(gradeColorsJson);
|
||||
return gradeColors;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -283,8 +283,16 @@ class _PremiumCustomAccentColorSettingState
|
||||
label: "understand".i18n,
|
||||
onTap: () async {
|
||||
Navigator.of(context).pop();
|
||||
SharedTheme theme = await shareProvider
|
||||
.shareCurrentTheme(context);
|
||||
|
||||
SharedGradeColors gradeColors =
|
||||
await shareProvider
|
||||
.shareCurrentGradeColors(context);
|
||||
SharedTheme theme =
|
||||
await shareProvider.shareCurrentTheme(
|
||||
context,
|
||||
gradeColors: gradeColors,
|
||||
);
|
||||
|
||||
Share.share(
|
||||
theme.id,
|
||||
subject: 'share_subj_theme'.i18n,
|
||||
@ -804,6 +812,18 @@ class _PremiumCustomAccentColorSettingState
|
||||
setTheme(settings.theme, true);
|
||||
},
|
||||
onThemeIdProvided: (theme) {
|
||||
// changing grade colors
|
||||
List<Color> colors = [
|
||||
theme.gradeColors.oneColor,
|
||||
theme.gradeColors.twoColor,
|
||||
theme.gradeColors.threeColor,
|
||||
theme.gradeColors.fourColor,
|
||||
theme.gradeColors.fiveColor,
|
||||
];
|
||||
settings.update(
|
||||
gradeColors: colors);
|
||||
|
||||
// changing theme
|
||||
setState(() {
|
||||
updateCustomColor(
|
||||
null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user