forked from firka/student-legacy
92 lines
2.4 KiB
Dart
92 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class SharedTheme {
|
|
Map json;
|
|
String id;
|
|
bool isPublic;
|
|
String nickname;
|
|
Color backgroundColor;
|
|
Color panelsColor;
|
|
Color accentColor;
|
|
Color iconColor;
|
|
bool shadowEffect;
|
|
SharedGradeColors gradeColors;
|
|
String displayName;
|
|
ThemeMode? themeMode;
|
|
String fontFamily;
|
|
|
|
SharedTheme({
|
|
required this.json,
|
|
required this.id,
|
|
this.isPublic = false,
|
|
this.nickname = 'Anonymous',
|
|
required this.backgroundColor,
|
|
required this.panelsColor,
|
|
required this.accentColor,
|
|
required this.iconColor,
|
|
required this.shadowEffect,
|
|
required this.gradeColors,
|
|
this.displayName = 'displayName',
|
|
this.themeMode,
|
|
required this.fontFamily,
|
|
});
|
|
|
|
factory SharedTheme.fromJson(Map json, SharedGradeColors gradeColors) {
|
|
return SharedTheme(
|
|
json: json,
|
|
id: json['public_id'],
|
|
isPublic: json['is_public'] ?? false,
|
|
nickname: json['nickname'] ?? 'Anonymous',
|
|
backgroundColor: Color(json['background_color']),
|
|
panelsColor: Color(json['panels_color']),
|
|
accentColor: Color(json['accent_color']),
|
|
iconColor: Color(json['icon_color']),
|
|
shadowEffect: json['shadow_effect'] ?? true,
|
|
gradeColors: gradeColors,
|
|
displayName: json['display_name'] ?? 'no_name',
|
|
themeMode: json['theme_mode'] == 'dark'
|
|
? ThemeMode.dark
|
|
: (json['theme_mode'] == 'light' ? ThemeMode.light : null),
|
|
fontFamily: json['font_family'] ?? '',
|
|
);
|
|
}
|
|
}
|
|
|
|
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']),
|
|
);
|
|
}
|
|
}
|