diff --git a/lib/ui/exclude/exclude_contacts_page.dart b/lib/ui/exclude/exclude_contacts_page.dart index b6052dd..2f9b778 100644 --- a/lib/ui/exclude/exclude_contacts_page.dart +++ b/lib/ui/exclude/exclude_contacts_page.dart @@ -1,12 +1,8 @@ import 'package:bot_toast/bot_toast.dart'; - import 'package:flutter/material.dart'; -import 'package:flutter_contacts/contact.dart'; import 'package:flutter_contacts/flutter_contacts.dart'; - import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; - import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; class ExcludeContactsPage extends StatefulWidget { @@ -17,20 +13,21 @@ class ExcludeContactsPage extends StatefulWidget { } class _ExcludeContactsPageState extends State { - late List contacts; + List? contacts; List numbers = []; List status = []; var flag = true; + bool _permissionDenied = false; @override void initState() { super.initState(); - _incrementCounter(); + _viewLoading(); } - Future _incrementCounter() async { + Future _viewLoading() async { contacts = await FlutterContacts.getContacts(); - for (var element in contacts) { + for (var element in contacts!) { final full = await FlutterContacts.getContact(element.id); numbers.add(full!.phones.first.number); status.add(false); @@ -41,17 +38,17 @@ class _ExcludeContactsPageState extends State { @override Widget build(BuildContext context) { var profileBuilder = FutureBuilder( - future: _incrementCounter(), + future: _viewLoading(), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.waiting && flag) { flag = false; return Container(); } else { return ListView.builder( - itemCount: contacts.length, + itemCount: contacts!.length, itemBuilder: (context, i) => ListTile( title: Text( - contacts[i].displayName, + contacts![i].displayName, style: TextStyle( fontSize: 32.sp, fontWeight: FontWeight.w600, diff --git a/lib/ui/exclude/exclude_single_page.dart b/lib/ui/exclude/exclude_single_page.dart index b1c994d..ec84cd2 100644 --- a/lib/ui/exclude/exclude_single_page.dart +++ b/lib/ui/exclude/exclude_single_page.dart @@ -1,12 +1,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:project_telephony/utils/headers.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; import 'package:velocity_x/velocity_x.dart'; -import '../../base/base_style.dart'; -import '../widget/plone_back_button.dart'; -import '../widget/plone_bottom.dart'; - class ExcludeSinglePage extends StatefulWidget { const ExcludeSinglePage({Key? key}) : super(key: key); @@ -15,96 +12,114 @@ class ExcludeSinglePage extends StatefulWidget { } class _ExcludeSinglePageState extends State { + late TextEditingController _phoneController; + late TextEditingController _nameController; + + @override + void initState() { + super.initState(); + _phoneController = TextEditingController(); + _nameController = TextEditingController(); + } + + @override + void dispose() { + super.dispose(); + _phoneController.dispose(); + _nameController.dispose(); + } - String phone=""; - String name=""; @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - elevation: 0, - title: Text( - '添加单个或批量号码', - style: TextStyle( - fontSize: BaseStyle.fontSize34, - color: BaseStyle.color333333, - fontWeight: FontWeight.bold), - ), - titleSpacing: 110.w, - leading: const CloudBackButton(isSpecial: true), - backgroundColor: kForeGroundColor), - backgroundColor: Colors.white, - body: Container( + return ScaffoldThemeWidget( + title: '添加单个或批量号码', + bottom: "添加", + onTap: () {}, + isOpacity: + _phoneController.text.isNotEmpty && _nameController.text.isNotEmpty, + child: Container( padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - addNumber("号码", "请输入号码"), - 40.hb, - addNumber("名称", "请输入名称"), - 43.hb, - Text( - "使用说明:", - style: TextStyle(color: BaseStyle.color999999, fontSize: 28.sp), + addNumber("号码", "请输入号码", _phoneController), + 15.heightBox, + addNumber("名称", "请输入名称", _nameController), + 30.heightBox, + RichText( + text: const TextSpan( + children: [ + TextSpan( + text: "使用说明:\n", + style: TextStyle( + fontWeight: FontWeight.w600, + color: Colors.black38, + ), + ), + TextSpan( + text: "如输入000*,可屏蔽所有000开头的号码", + style: TextStyle( + color: Colors.black38, + ), + ), + ], + ), ), - 12.hb, - Text("如输入00852*,可匹配所有00852开头的号码", - style: TextStyle(color: BaseStyle.color999999, fontSize: 28.sp)) - // RichText( - // text: const TextSpan( - // children: [ - // TextSpan(text: "使用说明:"), - // TextSpan(text: "如输入000*,可屏蔽所有000开头的号码") - // ], - // ), - // ), ], ), ), - bottomNavigationBar: PloneBottom( - onTap: (){}, - border: name.isEmpty || phone.isEmpty, - opacity:name.isEmpty || phone.isEmpty ? 0.4 : 1, - text: "添加", - ).paddingOnly(bottom: 30.w), ); } - addNumber(String title, content) { + addNumber(String title, content, TextEditingController controller) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, - style: TextStyle( - fontSize: 28.sp, - color: Colors.black38, + style: const TextStyle( + fontSize: 16, + color: Color(0xFF999999), fontWeight: FontWeight.w600, ), ), 15.heightBox, - CupertinoTextField( - padding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 20.w), - decoration: BoxDecoration( - border: Border.all(color: Colors.white), - // borderRadius: BorderRadius.all( - // Radius.circular(4.w) - // ), - color: const Color(0xFFF9F9F9)), - placeholderStyle: - TextStyle(color: BaseStyle.color999999, fontSize: 28.sp), - placeholder: content, + TextField( + controller: controller, onChanged: (value) { - if(title=="号码"){ - phone=value; - print("phone:$phone"); - }else{ - name=value; - print("name:$name"); - } setState(() {}); }, + decoration: InputDecoration( + contentPadding: EdgeInsets.all(30.w), + hintText: content, + hintStyle: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: Color(0xFF999999), + ), + fillColor: const Color(0xFFF9F9F9), + filled: true, + enabledBorder: const OutlineInputBorder( + /*边角*/ + borderRadius: BorderRadius.all( + Radius.circular(5), //边角为5 + ), + borderSide: BorderSide( + color: Colors.white, //边线颜色为白色 + width: 1, //边线宽度为2 + ), + ), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.white, //边框颜色为白色 + width: 1, //宽度为5 + ), + borderRadius: BorderRadius.all( + Radius.circular(5), //边角为30 + ), + ), + ), ), ], ); diff --git a/lib/ui/home/set/specify_phone_page.dart b/lib/ui/home/set/specify_phone_page.dart index 9b84ff1..a4fe73a 100644 --- a/lib/ui/home/set/specify_phone_page.dart +++ b/lib/ui/home/set/specify_phone_page.dart @@ -1,10 +1,10 @@ -import 'dart:ffi'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:project_telephony/constants/api.dart'; import 'package:project_telephony/model/network/api_client.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:project_telephony/ui/exclude/exclude_contacts_page.dart'; import 'package:project_telephony/ui/exclude/exclude_single_page.dart'; import 'package:project_telephony/ui/home/set/phone_num_list/call_records_list.dart'; @@ -15,7 +15,7 @@ import '../../../base/base_style.dart'; import '../../../model/exclude_phone_model.dart'; -import '../../widget/appdialog.dart'; + import '../../widget/scaffold_theme_widget.dart'; class SpecifyPhonePage extends StatefulWidget { @@ -70,8 +70,24 @@ class _SpecifyPhonePageState extends State { // Get.to(() => const CallRecordsList()); }), - _getAddPhone("通迅录添加", "通过本机通讯录添加号码", () { - Get.to(() => (const ExcludeContactsPage())); + _getAddPhone("通迅录添加", "通过本机通讯录添加号码", () async { + if(await Permission.contacts.isDenied){ + showDialog( + context: context, + builder: (context) { + return AlertDialog( + content: const Text('获取通讯录权限还未开启'), + actions: [ + ElevatedButton(onPressed: (){ + openAppSettings(); + }, + child: const Text("前往开启"),), + ], + ); + }); + }else{ + Get.to(() => (const ExcludeContactsPage())); + } }), _getAddPhone("添加单个或批量号码", "通过输入号码段添加批量号码", () { Get.to(() => (const ExcludeSinglePage())); diff --git a/lib/ui/login/login_page.dart b/lib/ui/login/login_page.dart index 0029904..6341349 100644 --- a/lib/ui/login/login_page.dart +++ b/lib/ui/login/login_page.dart @@ -40,10 +40,12 @@ class _LoginPageState extends State { int _countDownNum = 59; late TextEditingController _phoneController; late TextEditingController _smsCodeController; - late FocusNode _phoneFocusNode ; + late FocusNode _phoneFocusNode; + late FocusNode _smsCodeFocusNode; bool _cantSelected = false; DateTime? _lastTap; + @override void initState() { super.initState(); @@ -121,35 +123,36 @@ class _LoginPageState extends State { blM: false, border: _phoneController.text.length != 11, opacity: _phoneController.text.length == 11 ? 1 : 0.4, - onTap: () async{ + onTap: () async { // DateTime? _lastTap; if (_phoneController.text.length < 11) { BotToast.showText(text: "请输入手机号"); - }else if(_smsCodeController.text.length < 6){ + } else if (_smsCodeController.text.length < 6) { BotToast.showText(text: "请输入验证码"); - }else if(!_chooseAgreement){ + } else if (!_chooseAgreement) { BotToast.showText(text: "请同意并勾选隐私政策"); - }else{ - if(_lastTap != null &&DateTime.now().difference(_lastTap!).inSeconds < 2){ + } else { + if (_lastTap != null && + DateTime.now().difference(_lastTap!).inSeconds < 2) { // BotToast.showText(text: "过快"); - return ; + return; } - _lastTap = DateTime.now(); - var base = await apiClient.request(API.app.login, - data: {'phone': _phoneController.text, 'code': _smsCodeController.text}); - if (base.code == 0) { - print("123123${base.data['token']}"); - await UserTool.userProvider.setToken(base.data['token']); + _lastTap = DateTime.now(); + var base = await apiClient.request(API.app.login, data: { + 'phone': _phoneController.text, + 'code': _smsCodeController.text + }); + if (base.code == 0) { + print("123123${base.data['token']}"); + await UserTool.userProvider.setToken(base.data['token']); // print(a); - // print("4567899"); - Get.offAll(const TabNavigator()); - } - else { - CloudToast.show(base.msg); - } + // print("4567899"); + Get.offAll(const TabNavigator()); + } else { + CloudToast.show(base.msg); } - }, - + } + }, text: "立即登录", ), 32.hb, @@ -223,10 +226,12 @@ class _LoginPageState extends State { await apiClient.request(API.app.captcha, data: { 'phone': _phoneController.text, }); - var res= RegExp( r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$'); - if((_phoneController.text).isNotEmpty && res.hasMatch(_phoneController.text)){ + var res = RegExp( + r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$'); + if ((_phoneController.text).isNotEmpty && + res.hasMatch(_phoneController.text)) { _beginCountDown(); - }else{ + } else { BotToast.showText(text: "手机号不能为空且手机号格式错误"); } if (_cantSelected) return; @@ -308,9 +313,10 @@ class _LoginPageState extends State { final TapGestureRecognizer recognizer = TapGestureRecognizer(); recognizer.onTap = () { if (kDebugMode) { - Get.to(()=>const ContentAuthorityPage()); + Get.to(() => const ContentAuthorityPage()); // print("点击协议了"); } + ///跳转到用户协议页面 }; return recognizer; @@ -336,27 +342,28 @@ class _LoginPageState extends State { : const Icon(CupertinoIcons.checkmark_circle, size: 18, color: Colors.blue), ), - RichText( - text: TextSpan( - text: "我已阅读并同意", - style: TextStyle( - color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), - children: [ - // TextSpan( - // text: '《用户服务协议》', - // style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), - // recognizer: _recognizer(context, 2)), - // TextSpan( - // text: "和", - // style: TextStyle( - // color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), - // ), - TextSpan( - text: '《短信帮手隐私协议》', - style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), - recognizer: _recognizer(context, 2)), - ])) + text: TextSpan( + text: "我已阅读并同意", + style: + TextStyle(color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), + children: [ + // TextSpan( + // text: '《用户服务协议》', + // style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), + // recognizer: _recognizer(context, 2)), + // TextSpan( + // text: "和", + // style: TextStyle( + // color: BaseStyle.colorcccccc, fontSize: 12 * 2.sp), + // ), + TextSpan( + text: '《短信帮手隐私协议》', + style: TextStyle(color: kPrimaryColor, fontSize: 12 * 2.sp), + recognizer: _recognizer(context, 2)), + ], + ), + ), ], ), ); diff --git a/lib/ui/user/privacy_rights_page.dart b/lib/ui/user/privacy_rights_page.dart index 3bdec92..6cfd142 100644 --- a/lib/ui/user/privacy_rights_page.dart +++ b/lib/ui/user/privacy_rights_page.dart @@ -74,12 +74,7 @@ class _PrivacyRightsPageState extends State { bottomNavigationBar: GestureDetector( onTap: () async { await _launchUrl(); - // await launchUrlString("tel:13111111111"); }, - - // onTap: () async{ - // - // }, child: Container( margin: EdgeInsets.symmetric(horizontal: 64.w, vertical: 24.w), padding: EdgeInsets.symmetric(horizontal: 214.w, vertical: 26.w), @@ -95,21 +90,6 @@ class _PrivacyRightsPageState extends State { ); } - // Color getPermissionColor() { - // if(true){ - // return Colors.red; - // }else{ - // return Colors.green; - // } - // } - - // String getPermissionStu() { - // if (false) { - // return "未允许"; - // } else { - // return "已允许"; - // } - // } Future _launchUrl() async { if (!await launchUrl(_url)) { throw 'Could not launch $_url'; @@ -123,23 +103,6 @@ class _PrivacyRightsPageState extends State { openAppSettings(); setState(() {}); } - // if(!(sms && plone)){ - // // print(sms); - // // print(plone); - // openAppSettings(); - // }else{ - // // print("123123123123"); - // } - // await Permission.phone.request(); - // await Permission.sms.request(); - // Map statuses = await [ - // Permission.sms, - // Permission.phone, - // ].request(); - // - // openAppSettings(); - // print(await Permission.phone.request().isGranted); - // print(await Permission.sms.request().isGranted); }, title: Text( name, diff --git a/lib/ui/widget/scaffold_theme_widget.dart b/lib/ui/widget/scaffold_theme_widget.dart index 92914c3..86e79fb 100644 --- a/lib/ui/widget/scaffold_theme_widget.dart +++ b/lib/ui/widget/scaffold_theme_widget.dart @@ -29,7 +29,7 @@ class ScaffoldThemeWidget extends StatefulWidget { required this.title, required this.child, required this.bottom, - this.isBorder = false, + this.isBorder = true, this.isOpacity = true, required this.onTap, this.wid=162