profile picture in db
This commit is contained in:
parent
d09e41ee7d
commit
fdeb576ffa
@ -21,6 +21,7 @@ class UserProvider with ChangeNotifier {
|
||||
Role? get role => user?.role;
|
||||
Student? get student => user?.student;
|
||||
String? get nickname => user?.nickname;
|
||||
String get picture => user?.picture ?? "";
|
||||
String? get displayName => user?.displayName;
|
||||
|
||||
final SettingsProvider _settings;
|
||||
@ -70,4 +71,8 @@ class UserProvider with ChangeNotifier {
|
||||
List<User> getUsers() {
|
||||
return _users.values.toList();
|
||||
}
|
||||
|
||||
void refresh() {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ const settingsDB = DatabaseStruct("settings", {
|
||||
// YOU'VE BEEN WARNED!!!
|
||||
const usersDB = DatabaseStruct("users", {
|
||||
"id": String, "name": String, "username": String, "password": String, "institute_code": String, "student": String, "role": int,
|
||||
"nickname": String // premium only
|
||||
"nickname": String, "picture": String // premium only
|
||||
});
|
||||
const userDataDB = DatabaseStruct("user_data", {
|
||||
"id": String, "grades": String, "timetable": String, "exams": String, "homework": String, "messages": String, "notes": String,
|
||||
@ -62,7 +62,7 @@ Future<Database> initDB(DatabaseProvider database) async {
|
||||
await migrateDB(
|
||||
db,
|
||||
struct: usersDB,
|
||||
defaultValues: {"role": 0, "nickname": ""},
|
||||
defaultValues: {"role": 0, "nickname": "", "picture": ""},
|
||||
);
|
||||
await migrateDB(db, struct: userDataDB, defaultValues: {
|
||||
"grades": "[]", "timetable": "[]", "exams": "[]", "homework": "[]", "messages": "[]", "notes": "[]", "events": "[]", "absences": "[]",
|
||||
|
@ -14,6 +14,7 @@ class User {
|
||||
Student student;
|
||||
Role role;
|
||||
String nickname;
|
||||
String picture;
|
||||
|
||||
String get displayName => nickname != '' ? nickname : name;
|
||||
|
||||
@ -26,6 +27,7 @@ class User {
|
||||
required this.student,
|
||||
required this.role,
|
||||
this.nickname = "",
|
||||
this.picture = "",
|
||||
}) {
|
||||
if (id != null) {
|
||||
this.id = id;
|
||||
@ -44,6 +46,7 @@ class User {
|
||||
student: Student.fromJson(jsonDecode(map["student"])),
|
||||
role: Role.values[map["role"] ?? 0],
|
||||
nickname: map["nickname"] ?? "",
|
||||
picture: map["picture"] ?? "",
|
||||
);
|
||||
}
|
||||
|
||||
@ -57,6 +60,7 @@ class User {
|
||||
"student": jsonEncode(student.json),
|
||||
"role": role.index,
|
||||
"nickname": nickname,
|
||||
"picture": picture,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user