friend_stress_state.dart
1.63 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import 'package:doublefeel_flutter/r.dart';
import 'package:flutter/material.dart';
enum FriendStressState {
wait(0),
stressful(1),
slightStress(2),
normal(3),
energetic(4);
const FriendStressState(this.value);
final int value;
static FriendStressState fromValue(int? value) {
return switch (value) {
1 => FriendStressState.stressful,
2 => FriendStressState.slightStress,
3 => FriendStressState.normal,
4 => FriendStressState.energetic,
_ => FriendStressState.wait,
};
}
bool get hasData => this != FriendStressState.wait;
int? get segmentIndex {
return switch (this) {
FriendStressState.stressful => 0,
FriendStressState.slightStress => 1,
FriendStressState.normal => 2,
FriendStressState.energetic => 3,
FriendStressState.wait => null,
};
}
Color get color {
return switch (this) {
FriendStressState.stressful => const Color(0xFFFF5279),
FriendStressState.slightStress => const Color(0xFFFF9A6E),
FriendStressState.normal => const Color(0xFF7B9BFB),
FriendStressState.energetic => const Color(0xFF3BD49D),
FriendStressState.wait => const Color(0xFFF3F3F3),
};
}
String get iconPath {
return switch (this) {
FriendStressState.stressful => R.assetsImagesRealtimeStressOverloadIcon,
FriendStressState.slightStress =>
R.assetsImagesRealtimeStressAttentionIcon,
FriendStressState.normal => R.assetsImagesRealtimeStressNormalIcon,
FriendStressState.energetic => R.assetsImagesRealtimeStressExcellentIcon,
FriendStressState.wait => R.assetsImagesRealtimeStressNoDataIcon,
};
}
}