diff --git a/assets/icons/card.png b/assets/icons/card.png new file mode 100644 index 0000000..ba1200e Binary files /dev/null and b/assets/icons/card.png differ diff --git a/assets/images/cardbg.png b/assets/images/cardbg.png new file mode 100644 index 0000000..54dbbe8 Binary files /dev/null and b/assets/images/cardbg.png differ diff --git a/lib/gen/assets.gen.dart b/lib/gen/assets.gen.dart index 0c983d3..d783583 100644 --- a/lib/gen/assets.gen.dart +++ b/lib/gen/assets.gen.dart @@ -15,6 +15,9 @@ class $AssetsIconsGen { /// File path: assets/icons/Start.png AssetGenImage get start => const AssetGenImage('assets/icons/Start.png'); + /// File path: assets/icons/card.png + AssetGenImage get card => const AssetGenImage('assets/icons/card.png'); + /// File path: assets/icons/home_noSelected.png AssetGenImage get homeNoSelected => const AssetGenImage('assets/icons/home_noSelected.png'); @@ -99,6 +102,9 @@ class $AssetsImagesGen { AssetGenImage get bouncedbg => const AssetGenImage('assets/images/bouncedbg.png'); + /// File path: assets/images/cardbg.png + AssetGenImage get cardbg => const AssetGenImage('assets/images/cardbg.png'); + /// File path: assets/images/emptylist.png AssetGenImage get emptylist => const AssetGenImage('assets/images/emptylist.png'); diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index c49111c..3bb9bc6 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -48,17 +48,20 @@ class UserProvider extends ChangeNotifier { } Future setToken(String token, {User? user}) async { + final prefs = await SharedPreferences.getInstance(); apiClient.setToken(token); await HiveStore.appBox!.put('token', token); _isLogin = true; //每次打开app更新用户信息 await updateUserInfo(); + prefs.setInt("numIndex", 0); updateConSms(); updateRefSms(); updateCallSms(); updateIdleSms(); viewLoading(); getExclude(); + } Future logout() async { @@ -191,13 +194,13 @@ class UserProvider extends ChangeNotifier { } notifyListeners(); } - Future viewLoading() async { + Future viewLoading( ) async { List? numList=[]; List? numbers=[]; final service = FlutterBackgroundService(); final SharedPreferences prefs = await SharedPreferences.getInstance(); var contact = await FlutterContacts.getContacts(); - for (var element in contact!) { + for (var element in contact) { final full = await FlutterContacts.getContact(element.id); numbers.add(full!.phones.first.number.replaceAll(" ", "")); // status.add(false); @@ -206,14 +209,17 @@ class UserProvider extends ChangeNotifier { for (int i = 0; i < numberList.length; i++) { numList.add(numberList[i].phone); } - await prefs.setStringList("specified", numList); - await prefs.setStringList("addressList", numbers); + await prefs.setStringList("specified", numList ?? []); + await prefs.setStringList("addressList", numbers ?? []); + service.invoke("stopService"); if (prefs.getBool('kg')!) { Future.delayed(const Duration(seconds: 1), () async { service.startService(); }); } + + notifyListeners(); } } diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index 58c2577..c8c6f4d 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -60,7 +60,7 @@ void onStart(ServiceInstance service) async { bool? callSw = prefs.getBool('callSwitch'); bool? idleSw = prefs.getBool('idleSwitch'); int? numberSet = prefs.getInt("numIndex"); - List? numberList = prefs.getStringList("addressList"); + List? numberList = prefs.getStringList("addressList") ; List? noNumberList = prefs.getStringList("specified"); print("号码设置$numberSet 通讯列表$numberList 指定不发送$noNumberList"); if (callState == "IDLE") { @@ -71,7 +71,7 @@ void onStart(ServiceInstance service) async { print(phoneNum); switch (numberSet) { case 0: - if (!(noNumberList?.contains(phoneNum))!) { + if (!(noNumberList!.contains(phoneNum))) { if (flag > 0) { print("来电拒接/未接"); print("${phoneNum!}:${ref!}"); @@ -109,8 +109,8 @@ void onStart(ServiceInstance service) async { } break; case 1: - if ((numberList?.contains(phoneNum))! && - !(noNumberList?.contains(phoneNum))!) { + if ((numberList!.contains(phoneNum)) && + !(noNumberList!.contains(phoneNum))) { if (flag > 0) { print("来电拒接/未接"); print("${phoneNum!}:${ref!}"); @@ -148,8 +148,8 @@ void onStart(ServiceInstance service) async { } break; case 2: - if (!(numberList?.contains(phoneNum))! && - !(noNumberList?.contains(phoneNum))!) { + if (!(numberList!.contains(phoneNum)) && + !(noNumberList!.contains(phoneNum))) { if (flag > 0) { print("来电拒接/未接"); print("${phoneNum!}:${ref!}"); diff --git a/lib/ui/home/set/phone_set_page.dart b/lib/ui/home/set/phone_set_page.dart index 8ecf3c0..4a3d3d8 100644 --- a/lib/ui/home/set/phone_set_page.dart +++ b/lib/ui/home/set/phone_set_page.dart @@ -79,7 +79,8 @@ class _PhoneSetPageState extends State { // footer: MaterialFooter(), onRefresh: () async { final SharedPreferences prefs = await SharedPreferences.getInstance(); - select = (prefs.getInt("numIndex"))!; + print(prefs.getInt("numIndex")); + select = (prefs.getInt("numIndex")) ?? 0; // _viewLoading(); setState(() {}); }, diff --git a/lib/ui/user/members_page.dart b/lib/ui/user/members_page.dart index 58ec958..8c120a7 100644 --- a/lib/ui/user/members_page.dart +++ b/lib/ui/user/members_page.dart @@ -160,7 +160,7 @@ class _MembersPageState extends State { const CloudBackButton( isSpecial: true, ), - 154.wb, + 182.wb, Text('会员中心', style: Theme.of(context).textTheme.headline6), ], )), diff --git a/lib/ui/user/user_card_page.dart b/lib/ui/user/user_card_page.dart new file mode 100644 index 0000000..792ffbc --- /dev/null +++ b/lib/ui/user/user_card_page.dart @@ -0,0 +1,191 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:project_telephony/base/base_style.dart'; +import 'package:project_telephony/ui/widget/plone_bottom.dart'; +import 'package:project_telephony/utils/headers.dart'; +import 'package:project_telephony/utils/toast/cloud_toast.dart'; + +import '../widget/image_scaffold.dart'; + +class UserCardPage extends StatefulWidget { + const UserCardPage({Key? key}) : super(key: key); + + @override + _UserCardPageState createState() => _UserCardPageState(); +} + +class _UserCardPageState extends State { + String cardMi = ""; + + @override + Widget build(BuildContext context) { + return CloudScaffold( + systemStyle: const SystemUiOverlayStyle( + statusBarIconBrightness: Brightness.dark, + // systemNavigationBarColor: Colors.white, + ), + path: Assets.images.bg.path, + bodyColor: Colors.white, + extendBody: true, + body: Column( + children: [ + 44.hb, + ListTile( + leading: Padding( + padding: EdgeInsets.only(left: 32.w, right: 156.w), + child: const Icon( + Icons.chevron_left, + color: Colors.black, + ), + ), + onTap: () { + Get.back(); + }, + title: Text( + "卡密兑换", + style: TextStyle( + fontSize: 34.sp, + fontWeight: FontWeight.bold, + color: BaseStyle.color333333), + )), + 58.hb, + Container( + width: 750.w, + height: 700.w, + padding: EdgeInsets.symmetric(horizontal: 64.w), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(Assets.images.cardbg.path))), + child: Column( + children: [ + 88.hb, + Padding( + padding: EdgeInsets.only(left: 34.w), + child: getText(), + ), + 124.hb, + _getCard(), + 88.hb, + PloneBottom( + blM: false, + onTap: () { + if(cardMi.isEmpty){ + CloudToast.show("卡密为空"); + }else{ + CloudToast.show("卡密兑换成功"); + } + }, + border: cardMi.isEmpty?true:false, + opacity: cardMi.isEmpty? 0.4:1, + text: "立即兑换", + ) + ], + ), + ) + ], + )); + } + + _getCard() { + return TextField( + // controller: , + onChanged: (value) { + cardMi = value; + setState(() {}); + }, + decoration: InputDecoration( + contentPadding: EdgeInsets.all(30.w), + hintText: "请在此处输入卡密", + hintStyle: TextStyle( + fontSize: 28.sp, + fontWeight: FontWeight.w600, + color: const Color(0xFF999999), + ), + fillColor: const Color(0xFFFFFFFF), + filled: true, + enabledBorder: const OutlineInputBorder( + /*边角*/ + borderRadius: BorderRadius.all( + Radius.circular(5), //边角为5 + ), + borderSide: BorderSide( + color: Colors.white, //边线颜色为白色 + width: 0, //边线宽度为2 + ), + ), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.white, //边框颜色为白色 + width: 0, //宽度为5 + ), + borderRadius: BorderRadius.all( + Radius.circular(5), //边角为30 + ), + ), + ), + ); + } + + getText() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + "快速兑换", + style: TextStyle( + color: const Color(0xFFFFEAB0), + fontSize: 40.sp, + fontWeight: FontWeight.bold), + ), + 300.wb, + Text( + "VIP", + style: TextStyle( + color: const Color(0xFFE7F3FF), + fontFamily: "BlackItalic", + fontSize: 40.sp), + ), + ], + ), + 24.hb, + Text( + "短信帮手会员时长", + style: TextStyle(color: const Color(0xFFFFEAB0), fontSize: 24.sp), + ) + ], + ); + // RichText( + // text: const TextSpan( + // children: [ + // TextSpan( + // text: "快速兑换", + // style: TextStyle( + // fontWeight: FontWeight.w600, + // color: Colors.black38, + // ), + // ), + // TextSpan( + // text: "VIP \n", + // style: TextStyle( + // color: Colors.black38, + // ), + // ), + // TextSpan( + // text: "\n", + // style: TextStyle( + // color: Colors.black38, + // ), + // ), + // TextSpan( + // text: "vip", + // style: TextStyle( + // color: Colors.black38, + // ), + // ), + // ], + // ), + // ); + } +} diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index 09be0db..2a75c3b 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -11,6 +11,7 @@ import 'package:project_telephony/ui/tab_navigator.dart'; import 'package:project_telephony/ui/user/content_authority_page.dart'; import 'package:project_telephony/ui/user/members_page.dart'; import 'package:project_telephony/ui/user/privacy_rights_page.dart'; +import 'package:project_telephony/ui/user/user_card_page.dart'; 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'; @@ -152,14 +153,15 @@ class _UserPageState extends State { _getUser(), 72.hb, _getBanner(), - 120.hb, + 64.hb, _getSwitch2(), _getSwitch(Assets.icons.privacy.path, "隐私政策", false), _getSwitch( Assets.icons.permissions.path, "权限说明", false), _getSwitch(Assets.icons.sms.path, "短信标签", false), + _getSwitch(Assets.icons.card.path, "卡密兑换", false), // const Spacer(), - 182.hb, + 100.hb, UserTool.userProvider.isLogin ? PloneBottom( border: false, @@ -472,6 +474,9 @@ class _UserPageState extends State { name: name, )); break; + case "卡密兑换": + Get.to(()=>UserCardPage()); + break; default: break; }