|
|
|
@ -13,10 +13,12 @@ import 'package:project_telephony/ui/widget/image_scaffold.dart';
|
|
|
|
|
import 'package:project_telephony/ui/widget/plone_bottom.dart';
|
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
import 'package:telephony/telephony.dart';
|
|
|
|
|
import '../../constants/api.dart';
|
|
|
|
|
import '../../model/network/api_client.dart';
|
|
|
|
|
import '../../providers/user_provider.dart';
|
|
|
|
|
import '../../utils/hive_store.dart';
|
|
|
|
|
import '../../utils/toast/cloud_toast.dart';
|
|
|
|
|
import '../../utils/user_tool.dart';
|
|
|
|
|
import '../home/call.dart';
|
|
|
|
@ -36,19 +38,20 @@ final Telephony telephony = Telephony.instance;
|
|
|
|
|
class _UserPageState extends State<UserPage> {
|
|
|
|
|
// bool vle = PermissionStatus.denied.isGranted;
|
|
|
|
|
//bool vle =PermissionStatus.denied.isGranted;
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
|
|
|
|
final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
|
|
|
|
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
|
|
|
|
|
bool isVip = false;
|
|
|
|
|
String? endDate;
|
|
|
|
|
|
|
|
|
|
bool vle = UserTool.userProvider.userInfo.isVip==1;
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
if ( UserTool.userProvider.isLogin) {
|
|
|
|
|
if (UserTool.userProvider.userInfo.isVip == 1) {
|
|
|
|
|
isVip = true;
|
|
|
|
|
} else {
|
|
|
|
|
if (UserTool.userProvider.userInfo.end<=DateTime.now().millisecondsSinceEpoch ) {
|
|
|
|
|
isVip = false;
|
|
|
|
|
} else {
|
|
|
|
|
isVip = true;
|
|
|
|
|
}
|
|
|
|
|
endDate=DateUtil.formatDateMs(UserTool.userProvider.userInfo.end * 1000, format: DateFormats.y_mo_d);
|
|
|
|
|
}
|
|
|
|
@ -71,7 +74,7 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
72.hb,
|
|
|
|
|
_getBanner(),
|
|
|
|
|
120.hb,
|
|
|
|
|
_getSwitch(Assets.icons.switch1.path, "功能开关", true),
|
|
|
|
|
_getSwitch2(),
|
|
|
|
|
_getSwitch(Assets.icons.privacy.path, "隐私政策", false),
|
|
|
|
|
_getSwitch(Assets.icons.permissions.path, "权限说明", false),
|
|
|
|
|
_getSwitch(Assets.icons.sms.path, "短信标签", false),
|
|
|
|
@ -257,8 +260,55 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//内容
|
|
|
|
|
_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 {
|
|
|
|
|
final SharedPreferences prefs = await _prefs;
|
|
|
|
|
await prefs.setBool("kg", value);
|
|
|
|
|
print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
setState(() {
|
|
|
|
|
if(!isVip){
|
|
|
|
|
vle=value;
|
|
|
|
|
if(vle){
|
|
|
|
|
print("true");
|
|
|
|
|
UserTool.userProvider.setKg(vle);
|
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
|
BotToast.showText(text: " 你开启了该功能");
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
}else{
|
|
|
|
|
print("false");
|
|
|
|
|
UserTool.userProvider.setKg(vle);
|
|
|
|
|
// prefs.setBool("kg", vle);
|
|
|
|
|
BotToast.showText(text: "你已经关闭该功能");
|
|
|
|
|
// print("这是数据${prefs.getBool("kg")}");
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
BotToast.showText(text: "还没有开通会员,不可使用改功能");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
_getSwitch(String url, String name, bool pd) {
|
|
|
|
|
bool vle = true;
|
|
|
|
|
return GestureDetector(
|
|
|
|
|
onTap: () async {
|
|
|
|
|
if (!pd) {
|
|
|
|
@ -303,30 +353,7 @@ class _UserPageState extends State<UserPage> {
|
|
|
|
|
fontSize: BaseStyle.fontSize34,
|
|
|
|
|
fontWeight: FontWeight.bold),
|
|
|
|
|
),
|
|
|
|
|
trailing: pd
|
|
|
|
|
? Switch(
|
|
|
|
|
value: vle,
|
|
|
|
|
onChanged: (value) async {
|
|
|
|
|
// vle=value;
|
|
|
|
|
// await initializeService();
|
|
|
|
|
// await Permission.phone.request();
|
|
|
|
|
// List<Permission> permissions = [
|
|
|
|
|
// Permission.sms,
|
|
|
|
|
// Permission.phone,
|
|
|
|
|
// ];
|
|
|
|
|
// PermissionHelper.check(permissions, onSuccess: () {
|
|
|
|
|
// print('onSuccess');
|
|
|
|
|
// }, onFailed: () {
|
|
|
|
|
// print('onFailed');
|
|
|
|
|
// }, onOpenSetting: () {
|
|
|
|
|
// print('onOpenSetting');
|
|
|
|
|
// openAppSettings();
|
|
|
|
|
// });
|
|
|
|
|
setState(() {
|
|
|
|
|
vle=value;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
: const Icon(Icons.keyboard_arrow_right)),
|
|
|
|
|
trailing:const Icon(Icons.keyboard_arrow_right)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|