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 allThemes = "$themeGet/all";
static const themeByID = "$themeGet/"; static const themeByID = "$themeGet/";
static const gradeColorsShare = "$baseUrl/v2/shared/theme/add"; static const gradeColorsShare = "$baseUrl/v2/shared/grade-colors/add";
static const gradeColorsGet = "$baseUrl/v2/shared/theme/get"; static const gradeColorsGet = "$baseUrl/v2/shared/grade-colors/get";
static const allGradeColors = "$gradeColorsGet/all"; static const allGradeColors = "$gradeColorsGet/all";
static const gradeColorsByID = "$gradeColorsGet/"; static const gradeColorsByID = "$gradeColorsGet/";
@ -214,6 +214,9 @@ class FilcAPI {
theme.json['panels_color'] = theme.panelsColor.value.toString(); theme.json['panels_color'] = theme.panelsColor.value.toString();
theme.json['accent_color'] = theme.accentColor.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( http.Response res = await http.post(
Uri.parse(themeShare), Uri.parse(themeShare),
body: theme.json, body: theme.json,

View File

@ -21,7 +21,7 @@ class SharedTheme {
required this.gradeColors, required this.gradeColors,
}); });
factory SharedTheme.fromJson(Map json, Map gradeColorsJson) { factory SharedTheme.fromJson(Map json, SharedGradeColors gradeColors) {
return SharedTheme( return SharedTheme(
json: json, json: json,
id: json['public_id'], id: json['public_id'],
@ -30,7 +30,7 @@ class SharedTheme {
backgroundColor: Color(json['background_color']), backgroundColor: Color(json['background_color']),
panelsColor: Color(json['panels_color']), panelsColor: Color(json['panels_color']),
accentColor: Color(json['accent_color']), accentColor: Color(json['accent_color']),
gradeColors: SharedGradeColors.fromJson(gradeColorsJson), gradeColors: gradeColors,
); );
} }
} }
@ -45,7 +45,6 @@ class SharedGradeColors {
Color threeColor; Color threeColor;
Color twoColor; Color twoColor;
Color oneColor; Color oneColor;
String linkedThemeId;
SharedGradeColors({ SharedGradeColors({
required this.json, required this.json,
@ -57,7 +56,6 @@ class SharedGradeColors {
required this.threeColor, required this.threeColor,
required this.twoColor, required this.twoColor,
required this.oneColor, required this.oneColor,
required this.linkedThemeId,
}); });
factory SharedGradeColors.fromJson(Map json) { factory SharedGradeColors.fromJson(Map json) {
@ -71,7 +69,6 @@ class SharedGradeColors {
threeColor: Color(json['three_color']), threeColor: Color(json['three_color']),
twoColor: Color(json['two_color']), twoColor: Color(json['two_color']),
oneColor: Color(json['one_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); gradeProvider.grades, gradeProvider.lastSeenDate);
if (settingsProvider.gradeOpeningFun) { if (settingsProvider.gradeOpeningFun) {
items.addAll( items.addAll(
// ignore: use_build_context_synchronously
await getFilterWidgets(FilterType.newGrades, context: context)); await getFilterWidgets(FilterType.newGrades, context: context));
} }
break; break;

View File

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