|
|
|
@ -3,6 +3,7 @@ import 'package:flustars/flustars.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
import 'package:project_telephony/base/base_style.dart';
|
|
|
|
|
import 'package:project_telephony/ui/login/login_page.dart';
|
|
|
|
@ -46,36 +47,46 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
String? endDate;
|
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
|
|
|
|
|
|
late bool vle=false;
|
|
|
|
|
// bool vle=service.isRunning() as bool;
|
|
|
|
|
_load() async{
|
|
|
|
|
vle=await service.isRunning();
|
|
|
|
|
late bool vle = false;
|
|
|
|
|
|
|
|
|
|
_load() async {
|
|
|
|
|
vle = await service.isRunning();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final EasyRefreshController _easyRefreshController = EasyRefreshController();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_easyRefreshController.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
UserTool.userProvider.updateUserInfo();
|
|
|
|
|
Future.delayed(const Duration(milliseconds: 0), ()=>setState(() {
|
|
|
|
|
if ( UserTool.userProvider.isLogin) {
|
|
|
|
|
print(UserTool.userProvider.userInfo.end*1000);
|
|
|
|
|
print(DateTime.now().millisecondsSinceEpoch);
|
|
|
|
|
if (UserTool.userProvider.userInfo.end*1000>DateTime.now().microsecondsSinceEpoch) {
|
|
|
|
|
isVip = false;
|
|
|
|
|
vle=false;
|
|
|
|
|
} else {
|
|
|
|
|
isVip = true;
|
|
|
|
|
_load();
|
|
|
|
|
}
|
|
|
|
|
//service.isRunning() as bool;
|
|
|
|
|
endDate=DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d);
|
|
|
|
|
}else{
|
|
|
|
|
vle = false;
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
// Future.delayed(const Duration(milliseconds: 0), () async {
|
|
|
|
|
//
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
Future.delayed(
|
|
|
|
|
const Duration(milliseconds: 0),
|
|
|
|
|
() => setState(() {
|
|
|
|
|
if (UserTool.userProvider.isLogin) {
|
|
|
|
|
print(UserTool.userProvider.userInfo.end * 1000);
|
|
|
|
|
print(DateTime.now().millisecondsSinceEpoch);
|
|
|
|
|
if (UserTool.userProvider.userInfo.end * 1000 >
|
|
|
|
|
DateTime.now().microsecondsSinceEpoch) {
|
|
|
|
|
isVip = false;
|
|
|
|
|
vle = false;
|
|
|
|
|
} else {
|
|
|
|
|
isVip = true;
|
|
|
|
|
_load();
|
|
|
|
|
}
|
|
|
|
|
//service.isRunning() as bool;
|
|
|
|
|
endDate = DateUtil.formatDateMs(
|
|
|
|
|
UserTool.userProvider.userInfo.end * 1000,
|
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
|
} else {
|
|
|
|
|
vle = false;
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@ -88,39 +99,39 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
path: Assets.images.bg.path,
|
|
|
|
|
bodyColor: Colors.white,
|
|
|
|
|
extendBody: true,
|
|
|
|
|
|
|
|
|
|
body: Column(children: [
|
|
|
|
|
_getUser(),
|
|
|
|
|
72.hb,
|
|
|
|
|
_getBanner(),
|
|
|
|
|
120.hb,
|
|
|
|
|
_getSwitch2(),
|
|
|
|
|
_getSwitch(Assets.icons.privacy.path, "隐私政策", false),
|
|
|
|
|
_getSwitch(Assets.icons.permissions.path, "权限说明", false),
|
|
|
|
|
_getSwitch(Assets.icons.sms.path, "短信标签", false),
|
|
|
|
|
// const Spacer(),
|
|
|
|
|
182.hb,
|
|
|
|
|
UserTool. userProvider.isLogin
|
|
|
|
|
? PloneBottom(
|
|
|
|
|
border: false,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
|
|
|
|
|
var cancel = CloudToast.loading;
|
|
|
|
|
var base = await apiClient.request(API.app.logout,
|
|
|
|
|
showMessage: true);
|
|
|
|
|
if (base.code == 0) {
|
|
|
|
|
UserTool.userProvider.logout();
|
|
|
|
|
Get.offAll(const TabNavigator());
|
|
|
|
|
}
|
|
|
|
|
cancel();
|
|
|
|
|
},
|
|
|
|
|
textColor: const Color(0xFF1890FF),
|
|
|
|
|
color1: const Color(0xFFEBF5FF),
|
|
|
|
|
color2: const Color(0xFFEBF5FF),
|
|
|
|
|
text: "退出登录",
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox()
|
|
|
|
|
]),
|
|
|
|
|
body: Column(
|
|
|
|
|
children: [
|
|
|
|
|
_getUser(),
|
|
|
|
|
72.hb,
|
|
|
|
|
_getBanner(),
|
|
|
|
|
120.hb,
|
|
|
|
|
_getSwitch2(),
|
|
|
|
|
_getSwitch(Assets.icons.privacy.path, "隐私政策", false),
|
|
|
|
|
_getSwitch(Assets.icons.permissions.path, "权限说明", false),
|
|
|
|
|
_getSwitch(Assets.icons.sms.path, "短信标签", false),
|
|
|
|
|
// const Spacer(),
|
|
|
|
|
182.hb,
|
|
|
|
|
UserTool.userProvider.isLogin
|
|
|
|
|
? PloneBottom(
|
|
|
|
|
border: false,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
var cancel = CloudToast.loading;
|
|
|
|
|
var base = await apiClient.request(API.app.logout,
|
|
|
|
|
showMessage: true);
|
|
|
|
|
if (base.code == 0) {
|
|
|
|
|
UserTool.userProvider.logout();
|
|
|
|
|
Get.offAll(const TabNavigator());
|
|
|
|
|
}
|
|
|
|
|
cancel();
|
|
|
|
|
},
|
|
|
|
|
textColor: const Color(0xFF1890FF),
|
|
|
|
|
color1: const Color(0xFFEBF5FF),
|
|
|
|
|
color2: const Color(0xFFEBF5FF),
|
|
|
|
|
text: "退出登录",
|
|
|
|
|
)
|
|
|
|
|
: const SizedBox()
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -132,7 +143,7 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
children: [
|
|
|
|
|
GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
if(!userProvider.isLogin){
|
|
|
|
|
if (!userProvider.isLogin) {
|
|
|
|
|
Get.to(() => const LoginPage());
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
@ -140,8 +151,10 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
UserTool.userProvider.isLogin ?UserTool.userProvider.userInfo.name : "登录/注册",
|
|
|
|
|
// UserTool.userProvider.userInfo.name ,
|
|
|
|
|
UserTool.userProvider.isLogin
|
|
|
|
|
? UserTool.userProvider.userInfo.name
|
|
|
|
|
: "登录/注册",
|
|
|
|
|
// UserTool.userProvider.userInfo.name ,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: BaseStyle.fontSize48,
|
|
|
|
|
color: BaseStyle.color333333,
|
|
|
|
@ -168,7 +181,9 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
},
|
|
|
|
|
child: ClipOval(
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
UserTool.userProvider.isLogin?Assets.images.portraitDeep.path:Assets.images.portrait.path,
|
|
|
|
|
UserTool.userProvider.isLogin
|
|
|
|
|
? Assets.images.portraitDeep.path
|
|
|
|
|
: Assets.images.portrait.path,
|
|
|
|
|
height: 128.w,
|
|
|
|
|
width: 128.w,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
@ -185,35 +200,49 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
return SizedBox(
|
|
|
|
|
// margin: EdgeInsets.symmetric(horizontal: 32.w),
|
|
|
|
|
height: 144.w,
|
|
|
|
|
child: Stack(children: [
|
|
|
|
|
Align(
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
width: 622.w,
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
Assets.images.banner.path,
|
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
Positioned(
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
Align(
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
width: 622.w,
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
Assets.images.banner.path,
|
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
Positioned(
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 112.w, vertical: 24.w),
|
|
|
|
|
// margin: EdgeInsets.symmetric(horizontal: 64.w, vertical: 16.w),
|
|
|
|
|
// padding: EdgeInsets.symmetric(),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [_getText(), const Spacer(), _getBotton()],
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 112.w, vertical: 24.w),
|
|
|
|
|
// margin: EdgeInsets.symmetric(horizontal: 64.w, vertical: 16.w),
|
|
|
|
|
// padding: EdgeInsets.symmetric(),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [_getText(), const Spacer(), _getBotton()],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
))
|
|
|
|
|
]),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getRequests() async {
|
|
|
|
|
endDate = DateUtil.formatDateMs(
|
|
|
|
|
UserTool.userProvider.userInfo.end * 1000,
|
|
|
|
|
format: DateFormats.y_mo_d);
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//banner botton
|
|
|
|
|
_getBotton() {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
if(userProvider.isLogin){
|
|
|
|
|
Get.to(() => const MembersPage());
|
|
|
|
|
}else{
|
|
|
|
|
if (userProvider.isLogin) {
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.push(
|
|
|
|
|
MaterialPageRoute(builder: (_) => const MembersPage()),
|
|
|
|
|
)
|
|
|
|
|
.then((val) => _getRequests());
|
|
|
|
|
} else {
|
|
|
|
|
BotToast.showText(text: '您还未登录,请先登录!');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
@ -281,72 +310,73 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//内容
|
|
|
|
|
_getSwitch2(){
|
|
|
|
|
return Container(
|
|
|
|
|
_getSwitch2() {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 32.w),
|
|
|
|
|
child: ListTile(
|
|
|
|
|
// onTap: (() {}),
|
|
|
|
|
leading: Image.asset(
|
|
|
|
|
Assets.icons.switch1.path,
|
|
|
|
|
height: 54.w,
|
|
|
|
|
width: 56.w,
|
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
|
|
|
|
"功能开关",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: BaseStyle.color333333,
|
|
|
|
|
fontSize: BaseStyle.fontSize34,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
trailing: Switch(
|
|
|
|
|
value: vle,
|
|
|
|
|
onChanged: (value) async {
|
|
|
|
|
leading: Image.asset(
|
|
|
|
|
Assets.icons.switch1.path,
|
|
|
|
|
height: 54.w,
|
|
|
|
|
width: 56.w,
|
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
|
|
|
|
"功能开关",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: BaseStyle.color333333,
|
|
|
|
|
fontSize: BaseStyle.fontSize34,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
trailing: Switch(
|
|
|
|
|
value: vle,
|
|
|
|
|
onChanged: (value) async {
|
|
|
|
|
final SharedPreferences prefs = await _prefs;
|
|
|
|
|
// if(!value){
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// await prefs.setBool("kg", value);
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
setState(() {
|
|
|
|
|
if (isVip) {
|
|
|
|
|
vle = value;
|
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
|
// initializeService();
|
|
|
|
|
if (vle) {
|
|
|
|
|
print("true");
|
|
|
|
|
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 {
|
|
|
|
|
prefs.remove("kg");
|
|
|
|
|
prefs.setBool("kg", vle);
|
|
|
|
|
service.invoke("stopService");
|
|
|
|
|
|
|
|
|
|
final SharedPreferences prefs = await _prefs;
|
|
|
|
|
// if(!value){
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// await prefs.setBool("kg", value);
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
setState(() {
|
|
|
|
|
if(isVip){
|
|
|
|
|
vle=value;
|
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
|
// initializeService();
|
|
|
|
|
if(vle){
|
|
|
|
|
print("true");
|
|
|
|
|
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{
|
|
|
|
|
prefs.remove("kg");
|
|
|
|
|
prefs.setBool("kg", vle);
|
|
|
|
|
service.invoke("stopService");///有问题??
|
|
|
|
|
// exit(0);
|
|
|
|
|
///有问题??
|
|
|
|
|
// exit(0);
|
|
|
|
|
// UserTool.userProvider.setKg(vle);
|
|
|
|
|
// prefs.setBool("kg", false);
|
|
|
|
|
// initializeService();
|
|
|
|
|
// prefs.setBool("kg", false);
|
|
|
|
|
// initializeService();
|
|
|
|
|
|
|
|
|
|
BotToast.showText(text: "你已经关闭该功能");
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
BotToast.showText(text: "还没有开通会员,不可使用改功能");
|
|
|
|
|
BotToast.showText(text: "你已经关闭该功能");
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
));
|
|
|
|
|
} else {
|
|
|
|
|
BotToast.showText(text: "还没有开通会员,不可使用改功能");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getSwitch(String url, String name, bool pd) {
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () async {
|
|
|
|
@ -354,8 +384,9 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
switch (name) {
|
|
|
|
|
case "短信标签":
|
|
|
|
|
Get.to(() => ContentDetailsPage(
|
|
|
|
|
content:
|
|
|
|
|
UserTool.userProvider.isLogin ? UserTool.userProvider.userInfo.tag : "",
|
|
|
|
|
content: UserTool.userProvider.isLogin
|
|
|
|
|
? UserTool.userProvider.userInfo.tag
|
|
|
|
|
: "",
|
|
|
|
|
ploneBack: (String textContent) {
|
|
|
|
|
// print("这是数据" + textContent);
|
|
|
|
|
// textList.setAll(index, {textContent});
|
|
|
|
@ -392,7 +423,7 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
fontSize: BaseStyle.fontSize34,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
trailing:const Icon(Icons.keyboard_arrow_right)),
|
|
|
|
|
trailing: const Icon(Icons.keyboard_arrow_right)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|