mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add checkbox
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
String sp_UserINfo = "userinfo";
|
||||
String sp_Host = "host";
|
||||
String sp_Theme = "dart_mode";
|
||||
String spUserInfo = "userinfo";
|
||||
String spHost = "host";
|
||||
String spUserName = "username";
|
||||
String spPassWord = "password";
|
||||
String spTheme = "dart_mode";
|
||||
|
||||
@@ -21,11 +21,11 @@ class ThemeViewModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
bool isInDartMode() {
|
||||
return SpUtil.getBool(sp_Theme, defValue: false);
|
||||
return SpUtil.getBool(spTheme, defValue: false);
|
||||
}
|
||||
|
||||
void changeThemeReal(bool dark, [bool notify = true]) {
|
||||
SpUtil.putBool(sp_Theme, dark);
|
||||
SpUtil.putBool(spTheme, dark);
|
||||
if (!dark) {
|
||||
currentTheme = lightTheme;
|
||||
themeColor = LightThemeColors();
|
||||
@@ -39,7 +39,7 @@ class ThemeViewModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
void changeTheme() {
|
||||
changeThemeReal(!SpUtil.getBool(sp_Theme, defValue: false), true);
|
||||
changeThemeReal(!SpUtil.getBool(spTheme, defValue: false), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,20 @@ ThemeData darkTheme = ThemeData.dark().copyWith(
|
||||
secondary: _primaryColor,
|
||||
primary: _primaryColor,
|
||||
),
|
||||
toggleableActiveColor: _primaryColor,
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
checkColor: MaterialStateProperty.resolveWith(
|
||||
(Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return Colors.transparent;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.white;
|
||||
}
|
||||
return Colors.white;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
ThemeData lightTheme = ThemeData.light().copyWith(
|
||||
brightness: Brightness.light,
|
||||
@@ -122,6 +136,20 @@ ThemeData lightTheme = ThemeData.light().copyWith(
|
||||
borderSide: BorderSide(color: _primaryColor),
|
||||
),
|
||||
),
|
||||
toggleableActiveColor: _primaryColor,
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
checkColor: MaterialStateProperty.resolveWith(
|
||||
(Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return Colors.transparent;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.white;
|
||||
}
|
||||
return Colors.black;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
abstract class ThemeColors {
|
||||
|
||||
@@ -5,10 +5,14 @@ import 'sp_const.dart';
|
||||
class UserInfoViewModel {
|
||||
String? _token;
|
||||
String? _host = "";
|
||||
String? _userName;
|
||||
String? _passWord;
|
||||
|
||||
UserInfoViewModel() {
|
||||
String userInfoJson = SpUtil.getString(sp_UserINfo);
|
||||
_host = SpUtil.getString(sp_Host, defValue: "http://49.234.59.95:5700");
|
||||
String userInfoJson = SpUtil.getString(spUserInfo);
|
||||
_userName = SpUtil.getString(spUserName);
|
||||
_passWord = SpUtil.getString(spPassWord);
|
||||
_host = SpUtil.getString(spHost, defValue: "http://49.234.59.95:5700");
|
||||
if (userInfoJson.isNotEmpty) {
|
||||
_token = userInfoJson;
|
||||
}
|
||||
@@ -16,18 +20,29 @@ class UserInfoViewModel {
|
||||
|
||||
void updateToken(String token) {
|
||||
_token = token;
|
||||
SpUtil.putString(sp_UserINfo, token);
|
||||
SpUtil.putString(spUserInfo, token);
|
||||
}
|
||||
|
||||
void updateUserName(String userName, String password) {
|
||||
_userName = userName;
|
||||
_passWord = password;
|
||||
SpUtil.putString(spUserName, userName);
|
||||
SpUtil.putString(spPassWord, password);
|
||||
}
|
||||
|
||||
void updateHost(String host) {
|
||||
_host = host;
|
||||
SpUtil.putString(sp_Host, host);
|
||||
SpUtil.putString(spHost, host);
|
||||
}
|
||||
|
||||
String? get token => _token;
|
||||
|
||||
String? get host => _host;
|
||||
|
||||
String? get userName => _userName;
|
||||
|
||||
String? get passWord => _passWord;
|
||||
|
||||
bool isLogined() {
|
||||
return token != null && token!.isNotEmpty;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user