grade colors sharing works fine ahh

This commit is contained in:
Kima 2023-09-27 23:02:28 +02:00
parent 14ce4c82fb
commit 64fb22de74
4 changed files with 11 additions and 9 deletions

View File

@ -40,8 +40,8 @@ class FilcAPI {
static const allThemes = "$themeGet/all";
static const themeByID = "$themeGet/";
static const gradeColorsShare = "$baseUrl/v2/shared/theme/add";
static const gradeColorsGet = "$baseUrl/v2/shared/theme/get";
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/";
@ -214,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,

View File

@ -21,7 +21,7 @@ class SharedTheme {
required this.gradeColors,
});
factory SharedTheme.fromJson(Map json, Map gradeColorsJson) {
factory SharedTheme.fromJson(Map json, SharedGradeColors gradeColors) {
return SharedTheme(
json: json,
id: json['public_id'],
@ -30,7 +30,7 @@ class SharedTheme {
backgroundColor: Color(json['background_color']),
panelsColor: Color(json['panels_color']),
accentColor: Color(json['accent_color']),
gradeColors: SharedGradeColors.fromJson(gradeColorsJson),
gradeColors: gradeColors,
);
}
}
@ -45,7 +45,6 @@ class SharedGradeColors {
Color threeColor;
Color twoColor;
Color oneColor;
String linkedThemeId;
SharedGradeColors({
required this.json,
@ -57,7 +56,6 @@ class SharedGradeColors {
required this.threeColor,
required this.twoColor,
required this.oneColor,
required this.linkedThemeId,
});
factory SharedGradeColors.fromJson(Map json) {
@ -71,7 +69,6 @@ class SharedGradeColors {
threeColor: Color(json['three_color']),
twoColor: Color(json['two_color']),
oneColor: Color(json['one_color']),
linkedThemeId: json['linked_theme_id'],
);
}
}

View File

@ -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;

View File

@ -42,7 +42,7 @@ class ShareProvider extends ChangeNotifier {
const Color(0xFF3D7BF4).value,
};
SharedTheme theme = SharedTheme.fromJson(themeJson, gradeColors.json);
SharedTheme theme = SharedTheme.fromJson(themeJson, gradeColors);
FilcAPI.addSharedTheme(theme);
return theme;
@ -57,7 +57,8 @@ class ShareProvider extends ChangeNotifier {
await FilcAPI.getSharedGradeColors(themeJson['grade_colors_id']);
if (gradeColorsJson != null) {
SharedTheme theme = SharedTheme.fromJson(themeJson, gradeColorsJson);
SharedTheme theme = SharedTheme.fromJson(
themeJson, SharedGradeColors.fromJson(gradeColorsJson));
return theme;
}
}