-
Notifications
You must be signed in to change notification settings - Fork 1
/
Profile.ts
40 lines (37 loc) · 1.29 KB
/
Profile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { profile } from "../../Types/Puzzle.Types";
import { getKeyJSON, storeData } from "../AsyncStorage/AsyncStorage";
export class Profile {
public static async getProfile(): Promise<profile> {
let value = await getKeyJSON("profile");
if (value == null) {
let profile: profile = {
theme: true,
highlightBox: true,
highlightColumn: true,
highlightIdenticalValues: true,
highlightRow: true,
};
await this.setProfile(profile);
return profile;
}
return value;
}
public static async setProfile(profile: profile) {
storeData("profile", JSON.stringify(profile));
}
public static async setProfileValue(profileValue: string) {
let value: profile = await this.getProfile();
if (profileValue === "theme") {
value.theme = !value.theme;
} else if (profileValue === "highlightBox") {
value.highlightBox = !value.highlightBox;
} else if (profileValue === "highlightColumn") {
value.highlightColumn = !value.highlightColumn;
} else if (profileValue === "highlightIdenticalValues") {
value.highlightIdenticalValues = !value.highlightIdenticalValues;
} else if (profileValue === "highlightRow") {
value.highlightRow = !value.highlightRow;
}
this.setProfile(value);
}
}