登录界面

dyb
戴余标 2 years ago
parent 989a92af1a
commit f0136e906d

@ -12,19 +12,16 @@ import 'package:power_logger/power_logger.dart';
import 'package:project_telephony/providers/user_provider.dart'; import 'package:project_telephony/providers/user_provider.dart';
import 'package:project_telephony/ui/tab_navigator.dart'; import 'package:project_telephony/ui/tab_navigator.dart';
import 'package:project_telephony/ui/user/privacy_rights_page.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:telephony/telephony.dart'; import 'package:telephony/telephony.dart';
import 'package:project_telephony/utils/hive_store.dart'; import 'package:project_telephony/utils/hive_store.dart';
void _sendSMS(String message, List<String> recipients) async { void _sendSMS(String message, List<String> recipents) async {
try{ String _result = await sendSMS(message: message, recipients: recipents)
String result = .catchError((onError) {
await sendSMS(message: message, recipients: recipients, sendDirect: true); print(onError);
print(result); });
} on PlatformException catch(e){ print(_result);
print(e.toString());
}
} }
void main() async { void main() async {
@ -69,24 +66,33 @@ void onStart() {
Timer.periodic(const Duration(seconds: 1), (timer) async { Timer.periodic(const Duration(seconds: 1), (timer) async {
CallState state = await Telephony.instance.callState; CallState state = await Telephony.instance.callState;
callState = state.name; callState = state.name;
// print(callState!+"$flag"); print(callState!+" $flag");
if (callState == "IDLE") { if (callState == "IDLE") {
if (flag != 0) { if (flag != 0) {
flag = 0; flag = 0;
// print("object"); // print("object");
// final Iterable<CallLogEntry> result = await CallLog.query(); final Iterable<CallLogEntry> result = await CallLog.query();
// phoneNum = result.first.number; phoneNum = result.first.number;
// // print(phoneNum); // print(phoneNum);
List<String> recipents = ["13486828191"]; // String message = "This is a test message!";
// CallState state = await telephony.callState; // List<String> recipents = ["10000", "10086"];
_sendSMS("你好", recipents); // String _result = await sendSMS(message: message, recipients: recipents, sendDirect: true)
// phoneNum = result.first.number; // .catchError((onError) {
// // print(phoneNum); // print(onError);
// Phone.telephony.sendSms( // });
// to: phoneNum!, // print(_result);
// message: "hello", phoneNum = result.first.number;
// isMultipart: true, print(phoneNum);
// ); final SmsSendStatusListener listener = (SendStatus status) {
print(status);
};
Phone.telephony.sendSms(
to: phoneNum!,
message: "hello",
statusListener: listener,
isMultipart: true,
);
} }
} else if (callState == "RINGING") { } else if (callState == "RINGING") {
flag++; flag++;

@ -132,7 +132,7 @@ class _LoginPageState extends State<LoginPage> {
data: {'phone': _phoneController.text, 'code': _smsCodeController.text}); data: {'phone': _phoneController.text, 'code': _smsCodeController.text});
if (base.code == 0) { if (base.code == 0) {
await UserTool.userProvider.setToken(base.data['token']); await UserTool.userProvider.setToken(base.data['token']);
Get.back(); Get.to(() => const TabNavigator());
} else { } else {
CloudToast.show(base.msg); CloudToast.show(base.msg);
} }

@ -5,6 +5,7 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'; import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart';
import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/login/login_page.dart'; import 'package:project_telephony/ui/login/login_page.dart';
import 'package:project_telephony/ui/tab_navigator.dart';
import 'package:project_telephony/ui/user/members_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/privacy_rights_page.dart';
import 'package:project_telephony/ui/widget/image_scaffold.dart'; import 'package:project_telephony/ui/widget/image_scaffold.dart';
@ -12,9 +13,15 @@ import 'package:project_telephony/ui/widget/plone_bottom.dart';
import 'package:project_telephony/ui/widget/plone_image_picker.dart'; import 'package:project_telephony/ui/widget/plone_image_picker.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/permissionutils.dart'; import 'package:project_telephony/utils/permissionutils.dart';
import 'package:provider/provider.dart';
import 'package:telephony/telephony.dart'; import 'package:telephony/telephony.dart';
import '../../constants/api.dart';
import '../../model/network/api_client.dart';
import '../../permission.dart'; import '../../permission.dart';
import '../../providers/user_provider.dart';
import '../../utils/toast/cloud_toast.dart';
import '../../utils/user_tool.dart';
import '../home/home_page.dart'; import '../home/home_page.dart';
class UserPage extends StatefulWidget { class UserPage extends StatefulWidget {
@ -26,13 +33,9 @@ class UserPage extends StatefulWidget {
final Telephony telephony = Telephony.instance; final Telephony telephony = Telephony.instance;
@override
void initState() {}
class _UserPageState extends State<UserPage> { class _UserPageState extends State<UserPage> {
bool vle = false; bool vle = false;
bool tooken = true; final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -55,17 +58,24 @@ class _UserPageState extends State<UserPage> {
_getSwitch(Assets.icons.sms.path, "短信标签", false), _getSwitch(Assets.icons.sms.path, "短信标签", false),
// const Spacer(), // const Spacer(),
182.hb, 182.hb,
tooken? userProvider.isLogin
PloneBottom( ? PloneBottom(
border: false, border: false,
onTap: () { onTap: () async{
Get.to(() => const HomePage()); var cancel = CloudToast.loading;
}, var base = await apiClient.request(API.manager.logout, showMessage: true);
textColor: const Color(0xFF1890FF), if (base.code == 0) {
color1: const Color(0xFFEBF5FF), UserTool.userProvider.logout();
color2: const Color(0xFFEBF5FF), Get.offAll(const HomePage());
text: "退出登录", }
):const SizedBox() cancel();
},
textColor: const Color(0xFF1890FF),
color1: const Color(0xFFEBF5FF),
color2: const Color(0xFFEBF5FF),
text: "退出登录",
)
: const SizedBox()
]), ]),
); );
} }
@ -84,7 +94,7 @@ class _UserPageState extends State<UserPage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
tooken? "xxxxx": "登录/注册" , userProvider.isLogin ? userProvider.userInfo.name : "登录/注册",
style: TextStyle( style: TextStyle(
fontSize: BaseStyle.fontSize48, fontSize: BaseStyle.fontSize48,
color: BaseStyle.color333333, color: BaseStyle.color333333,
@ -92,7 +102,7 @@ class _UserPageState extends State<UserPage> {
), ),
24.hb, 24.hb,
Text( Text(
tooken ? "登录获取更多信息" : "欢迎您登录短信帮手", userProvider.isLogin ? "欢迎您登录短信帮手" : "登录获取更多信息",
style: TextStyle( style: TextStyle(
fontSize: BaseStyle.fontSize28, fontSize: BaseStyle.fontSize28,
color: BaseStyle.color333333), color: BaseStyle.color333333),

Loading…
Cancel
Save