|
|
|
@ -43,16 +43,21 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
|
|
|
|
bool isVip = false;
|
|
|
|
|
String? endDate;
|
|
|
|
|
late bool vle;
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
if ( UserTool.userProvider.isLogin) {
|
|
|
|
|
if (UserTool.userProvider.userInfo.end<=DateTime.now().millisecondsSinceEpoch ) {
|
|
|
|
|
isVip = false;
|
|
|
|
|
vle =false;
|
|
|
|
|
} else {
|
|
|
|
|
vle =true;
|
|
|
|
|
isVip = true;
|
|
|
|
|
}
|
|
|
|
|
endDate=DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d);
|
|
|
|
|
}else{
|
|
|
|
|
vle = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -278,24 +283,45 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
trailing: Switch(
|
|
|
|
|
value: isVip,
|
|
|
|
|
value: vle,
|
|
|
|
|
onChanged: (value) async {
|
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
|
var isRunning = await service.isRunning();
|
|
|
|
|
final SharedPreferences prefs = await _prefs;
|
|
|
|
|
await prefs.setBool("kg", value);
|
|
|
|
|
print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
// if(!value){
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// await prefs.setBool("kg", value);
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
setState(() {
|
|
|
|
|
if(!isVip){
|
|
|
|
|
isVip=value;
|
|
|
|
|
if(isVip){
|
|
|
|
|
vle=value;
|
|
|
|
|
|
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
|
// initializeService();
|
|
|
|
|
if(vle){
|
|
|
|
|
print("true");
|
|
|
|
|
UserTool.userProvider.setKg(isVip);
|
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
|
prefs.remove("kg");
|
|
|
|
|
prefs.setBool("kg", vle);
|
|
|
|
|
service.startService();
|
|
|
|
|
// WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
// initializeService();
|
|
|
|
|
// UserTool.userProvider.setKg(vle)
|
|
|
|
|
// initializeService();
|
|
|
|
|
// initializeService();
|
|
|
|
|
BotToast.showText(text: " 你开启了该功能");
|
|
|
|
|
// initializeService();
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
}else{
|
|
|
|
|
print("false");
|
|
|
|
|
UserTool.userProvider.setKg(isVip);
|
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
|
prefs.remove("kg");
|
|
|
|
|
prefs.setBool("kg", vle);
|
|
|
|
|
service.invoke("stopService");
|
|
|
|
|
// exit(0);
|
|
|
|
|
// UserTool.userProvider.setKg(vle);
|
|
|
|
|
// prefs.setBool("kg", false);
|
|
|
|
|
// initializeService();
|
|
|
|
|
|
|
|
|
|
BotToast.showText(text: "你已经关闭该功能");
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
}
|
|
|
|
|