# Conflicts:
#	lib/ui/home/content_connect_page.dart
master
戴余标 2 years ago
commit c6d424ceaa

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen --> <!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" /> <item android:drawable="@android:color/white" >
<!-- <bitmap android:src="@android/Start"></bitmap>-->
</item>
<!-- You can insert your own image assets here --> <!-- You can insert your own image assets here -->
<!-- <item> <!-- <item>

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

@ -47,6 +47,12 @@ class $AssetsIconsGen {
/// File path: assets/icons/zhifubao.png /// File path: assets/icons/zhifubao.png
AssetGenImage get zhifubao => AssetGenImage get zhifubao =>
const AssetGenImage('assets/icons/zhifubao.png'); const AssetGenImage('assets/icons/zhifubao.png');
/// File path: assets/icons/right.png
AssetGenImage get right =>
const AssetGenImage('assets/icons/right.png');
/// File path: assets/icons/horn.png
AssetGenImage get horn =>
const AssetGenImage('assets/icons/horn.png');
} }
class $AssetsImagesGen { class $AssetsImagesGen {
@ -81,6 +87,8 @@ class $AssetsImagesGen {
/// File path: assets/images/vipbg.png /// File path: assets/images/vipbg.png
AssetGenImage get vipbg => const AssetGenImage('assets/images/vipbg.png'); AssetGenImage get vipbg => const AssetGenImage('assets/images/vipbg.png');
/// File path: assets/images/Start.png
AssetGenImage get Start => const AssetGenImage('assets/images/Start.png');
} }
class Assets { class Assets {

@ -16,6 +16,7 @@ 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/home/call.dart'; import 'package:project_telephony/ui/home/call.dart';
import 'package:project_telephony/ui/loading.dart';
import 'package:project_telephony/ui/tab_navigator.dart'; import 'package:project_telephony/ui/tab_navigator.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -28,10 +29,19 @@ import 'package:project_telephony/utils/hive_store.dart';
void main() async { void main() async {
FlutterError.onError = (details) { // SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( //
LoggerData.addData(details); // statusBarColor: Colors.transparent,
FlutterError.presentError(details); // statusBarIconBrightness: Brightness.dark,
}; // ));
//
// WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();//
// FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
//
// await SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp] );
// FlutterError.onError = (details) {
// LoggerData.addData(details);
// FlutterError.presentError(details);
// };
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await initializeService(); await initializeService();
// Workmanager().initialize( // Workmanager().initialize(
@ -92,7 +102,11 @@ class _MyAppState extends State<MyApp> {
child: GetMaterialApp( child: GetMaterialApp(
// get.testmode=true, // get.testmode=true,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
home: const TabNavigator(), initialRoute: "/",
routes: {
"/TabNavigator":(context)=>const TabNavigator()
},
home: Loading(),//const TabNavigator(),
builder: (context, child) { builder: (context, child) {
// ScreenUtil.setContext(context); // ScreenUtil.setContext(context);
return MediaQuery( return MediaQuery(

@ -0,0 +1,19 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'state_model.g.dart';
@JsonSerializable()
class StateModel extends Equatable{
bool sms;
bool phone;
factory StateModel.fromJson(Map<String, dynamic> json) =>_$StateModelFromJson(json);
StateModel({
required this.sms,
required this.phone,
});
@override
List<Object?> get props => [sms,phone];
}

@ -0,0 +1,12 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'state_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
StateModel _$StateModelFromJson(Map<String, dynamic> json) => StateModel(
sms: json['sms'] as bool,
phone: json['phone'] as bool,
);

@ -0,0 +1,7 @@
// import 'package:flutter/material.dart';
//
// class PhoneProvider extends ChangeNotifier{
// bool sms=false;
// bool phone=false;
//
// }

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../base/base_style.dart'; import '../../base/base_style.dart';
@ -24,14 +25,14 @@ class AddSmsPage extends StatefulWidget {
class _AddSmsPageState extends State<AddSmsPage> { class _AddSmsPageState extends State<AddSmsPage> {
late TextEditingController _controller; late TextEditingController _controller;
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
String contant="";
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_controller = TextEditingController(); _controller = TextEditingController();
} }
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -70,6 +71,10 @@ class _AddSmsPageState extends State<AddSmsPage> {
color: BaseStyle.color333333, color: BaseStyle.color333333,
fontSize: BaseStyle.fontSize28, fontSize: BaseStyle.fontSize28,
), ),
onChanged: (text) async{
contant=text;
setState((){});
},
controller: _controller, controller: _controller,
decoration: const InputDecoration( decoration: const InputDecoration(
fillColor: Colors.transparent, fillColor: Colors.transparent,
@ -84,8 +89,9 @@ class _AddSmsPageState extends State<AddSmsPage> {
), ),
bottomNavigationBar: PloneBottom( bottomNavigationBar: PloneBottom(
border: _controller.text.isEmpty, border: _controller.text.isEmpty,
opacity: _controller.text.isNotEmpty ? 1 : 0.4, opacity: contant.isEmpty ? 0.4 : 1,
onTap: () async { onTap: () async {
BaseModel res = await apiClient.request(API.app.content, data: { BaseModel res = await apiClient.request(API.app.content, data: {
'content': _controller.text, 'content': _controller.text,
'status': widget.status, 'status': widget.status,
@ -93,7 +99,8 @@ class _AddSmsPageState extends State<AddSmsPage> {
if (res.code == 0) { if (res.code == 0) {
setState(() {}); setState(() {});
widget.ploneBack(_controller.text); widget.ploneBack(_controller.text);
userProvider.updateUserInfo(); UserTool.userProvider.updateUserInfo();
// userProvider.updateUserInfo();
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);
} }

@ -3,8 +3,11 @@ import 'dart:async';
import 'dart:ui'; import 'dart:ui';
import 'package:call_log/call_log.dart'; import 'package:call_log/call_log.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart';
import 'package:telephony/telephony.dart'; import 'package:telephony/telephony.dart';
@ -44,24 +47,30 @@ bool onIosBackground(ServiceInstance service) {
void onStart(ServiceInstance service ) async { void onStart(ServiceInstance service ) async {
DartPluginRegistrant.ensureInitialized(); DartPluginRegistrant.ensureInitialized();
int flag = 0; int flag = 0;
String phoneNum=""; String? phoneNum="";
String callState; String callState;
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();
phoneNum = result.first.number!; final Iterable<CallLogEntry> entry = await CallLog.query();
if(phoneNum.isEmpty){ phoneNum = entry.first.number;
// print('DATE : ${DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!)}');//
// print('DURATION : ${entry.first.duration}');///
if(phoneNum!.isEmpty){
print("At Least 1 Person or Message Required"); print("At Least 1 Person or Message Required");
}else{ }else{
print("你好$phoneNum"); print("你好$phoneNum");
// final inbox = telephony.getInboxSms(); // final inbox = telephony.getInboxSms();
Telephony.backgroundInstance.sendSms(to: phoneNum, message: "啦啦啦啦啦"); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "啦啦啦啦啦");
// telephony.sendSms(to: phoneNum, message: "感谢来电"); // telephony.sendSms(to: phoneNum, message: "感谢来电");
// _sendSMS('',[phoneNum]); // _sendSMS('',[phoneNum]);
// print("你好123123$phoneNum"); // print("你好123123$phoneNum");

@ -6,6 +6,7 @@ import 'package:project_telephony/ui/home/add_sms_page.dart';
import 'package:project_telephony/ui/widget/centertipsalterwidget.dart'; import 'package:project_telephony/ui/widget/centertipsalterwidget.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../constants/api.dart'; import '../../constants/api.dart';
import '../../model/network/api_client.dart'; import '../../model/network/api_client.dart';
@ -26,7 +27,7 @@ class _ContentConnectPageState extends State<ContentConnectPage> {
List<String> textListSMS = []; List<String> textListSMS = [];
int isCheck=0; int isCheck=0;
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); // final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
final EasyRefreshController _easyRefreshController = EasyRefreshController(); final EasyRefreshController _easyRefreshController = EasyRefreshController();
@override @override
@ -42,11 +43,11 @@ class _ContentConnectPageState extends State<ContentConnectPage> {
} }
updateList() { updateList() {
if (userProvider.isLogin) { if (UserTool.userProvider.isLogin) {
textListSMS.clear(); textListSMS.clear();
smsIdList.clear(); smsIdList.clear();
int i=0; int i=0;
userProvider.userInfo.contentCon?.forEach((model) { UserTool.userProvider.userInfo.contentCon?.forEach((model) {
textListSMS.add(model.content); textListSMS.add(model.content);
smsIdList.add(model.id); smsIdList.add(model.id);
if(model.isChecked==1){ if(model.isChecked==1){
@ -88,7 +89,7 @@ class _ContentConnectPageState extends State<ContentConnectPage> {
footer: MaterialFooter(), footer: MaterialFooter(),
controller: _easyRefreshController, controller: _easyRefreshController,
onRefresh: () async { onRefresh: () async {
await userProvider.updateUserInfo(); await UserTool.userProvider.updateUserInfo();
updateList(); updateList();
setState(() {}); setState(() {});
}, },
@ -109,13 +110,13 @@ class _ContentConnectPageState extends State<ContentConnectPage> {
data: {'id': smsIdList[index], 'status': 1}); data: {'id': smsIdList[index], 'status': 1});
if (res.code == 0) { if (res.code == 0) {
setState(() {}); setState(() {});
userProvider.updateUserInfo(); UserTool.userProvider.updateUserInfo();
_easyRefreshController.callRefresh(); _easyRefreshController.callRefresh();
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);
} }
} else { } else {
if (userProvider.isLogin) { if (UserTool.userProvider.isLogin) {
if (textListSMS.length > 5) { if (textListSMS.length > 5) {
BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信'); BotToast.showText(text: '自定义数量已达上限,请先删除不需要的短信');
} else { } else {

@ -1,11 +1,14 @@
import 'dart:async'; import 'dart:async';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/ui/home/content_connect_page.dart'; import 'package:project_telephony/ui/home/content_connect_page.dart';
import 'package:project_telephony/ui/home/content_refuse_page.dart'; import 'package:project_telephony/ui/home/content_refuse_page.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'call.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key); const HomePage({Key? key}) : super(key: key);
@ -14,11 +17,25 @@ class HomePage extends StatefulWidget {
_HomePageState createState() => _HomePageState(); _HomePageState createState() => _HomePageState();
} }
bool sms=false;
bool plone=false;
@override
class _HomePageState extends State<HomePage> { class _HomePageState extends State<HomePage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
// initializeService(); _listenForPermissionStatus();
setState(() {
});
}
Future<void> _listenForPermissionStatus() async {
sms=await Permission.sms.request().isGranted;
plone =await Permission.phone.request().isGranted;
setState(() {}); setState(() {});
} }
@ -30,23 +47,64 @@ class _HomePageState extends State<HomePage> {
extendBody: true, extendBody: true,
body: SafeArea( body: SafeArea(
child: Stack( child: Stack(
fit: StackFit.expand, // fit: StackFit.expand,
children: [ children: [
Positioned( Positioned(
top: 10.w, top: 10.w,
child: Image.asset( child:
// Container(
// height: 722.w,
// width: 722.w,
// decoration: BoxDecoration(image: DecorationImage(image:AssetImage(Assets.images.homeBg.path),fit:BoxFit.fill)),
// child: _warning(),)
Image.asset(
Assets.images.homeBg.path, Assets.images.homeBg.path,
height: 722.w, height: 722.w,
width: 722.w, width: 722.w,
), ),
), ),
Positioned(bottom: 20.w, child: _getBody()), Positioned(top: 48.w,child: _warning()),
Positioned(bottom: 64.w, child: _getBody()),
Align(child: SizedBox(width: double.infinity,height: 1600.w,),)
], ],
), ),
)); ));
} }
_getBody() { bool _getPermissions() {
if(sms && plone){
return true;
}else{
return false;
}
}
_warning() {
return Offstage(offstage: (sms && plone) ,child:
GestureDetector(
onTap: (){
// print();
openAppSettings();
},
child: Container(
margin: EdgeInsets.symmetric(horizontal: 64.w),
padding: EdgeInsets.symmetric(horizontal: 32.w,vertical: 20.w),
height: 88.w,
decoration: BoxDecoration(
borderRadius:BorderRadius.circular(8.w),
color: const Color(0xFFFFF2F2),
border: Border.all(width: 1.w,color: const Color(0xFFFFC8C8))
),
child: Row(children: [
Image(image: AssetImage(Assets.icons.horn.path),width: 48.w,height: 48.w
,),
16.wb,
Text("必须权限没有授予本APP无法正常使用",style: TextStyle(color: const Color(0xFFFF3F3F),fontSize:24.sp ),)
,32.wb,
Image(image: AssetImage(Assets.icons.right.path),width:28.w ,height: 28.w,fit:BoxFit.fill,)
],),
),),);
}
_getBody() {
return Container( return Container(
padding: EdgeInsets.symmetric(horizontal: 64.w), padding: EdgeInsets.symmetric(horizontal: 64.w),
child: Column( child: Column(
@ -86,70 +144,44 @@ class _HomePageState extends State<HomePage> {
print("未接听"); print("未接听");
} }
}, },
child: Stack( child: Container(
children: [ decoration: BoxDecoration(
Align( borderRadius: BorderRadius.circular(16.w),
child: Container( gradient: LinearGradient(
decoration: BoxDecoration( begin: Alignment.centerLeft,
borderRadius: BorderRadius.circular(16.w), end: Alignment.centerRight,
gradient: LinearGradient( colors: [cl1, cl2])),
begin: Alignment.centerLeft, width: 622.w,
end: Alignment.centerRight, height: 192.w,
colors: [cl1, cl2])), child: Row(children: [
width: 622.w, Container(
height: 192.w, padding: EdgeInsets.only(top: 40.w,left: 50.w
), ),
), child:
Positioned( Column(
// top: 0, crossAxisAlignment: CrossAxisAlignment.start,
// left: 0, children: [
child: Container(
// height: 192.w, Text(title,
// alignment: Alignment.centerLeft, style: TextStyle(
padding: EdgeInsets.only( fontSize: 36.sp,
left: 48.w, color: const Color(0xFFFFFFFF),
top: 38.w, fontWeight: FontWeight.bold)),
), 16.hb,
child: Column( Text(
crossAxisAlignment: CrossAxisAlignment.start, text,
children: [ style: TextStyle(
Text(title, fontSize: 27.sp,
style: TextStyle( color: const Color(0xFFFFFFFF).withOpacity(0.6)),
fontSize: 36.sp,
color: const Color(0xFFFFFFFF),
fontWeight: FontWeight.bold)),
16.hb,
Text(
text,
style: TextStyle(
fontSize: 27.sp,
color: const Color(0xFFFFFFFF).withOpacity(0.6)),
),
],
), ),
), ],
), ),),
Positioned( const Spacer()
bottom: 0, ,Image.asset(
right: 0, image,
child: Image.asset( width: 166.w,
image, height: 152.w,
width: 166.w, fit: BoxFit.fill,
height: 152.w, ),],)));
fit: BoxFit.fill,
),
)
],
)
// Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(16.w),
// gradient: LinearGradient(
// end: Alignment.centerLeft,
// begin: Alignment.centerRight,
// colors: [cl1, cl2])),
// child:
// ),
);
} }
} }

@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:project_telephony/utils/headers.dart';
class Loading extends StatefulWidget {
Loading({Key? key}) : super(key: key);
@override
_LoadingState createState() => _LoadingState();
}
class _LoadingState extends State<Loading> {
@override
void initState() {
// TODO: implement initState
super.initState();
Future.delayed(const Duration(seconds: 3),(){
//3
Navigator.of(context).pushReplacementNamed("/TabNavigator");
});
}
@override
Widget build(BuildContext context) {
//
return Scaffold(
backgroundColor: Colors.white,
body:Padding(padding: EdgeInsets.only(left: 148.w,top:1318.w ),child: Image.asset(
Assets.images.Start.path,width:434.sp,height:148.sp , fit: BoxFit.fill),)
,);
}
}

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/user_tool.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../base/base_style.dart'; import '../../base/base_style.dart';
@ -26,7 +27,7 @@ class ContentDetailsPage extends StatefulWidget {
class _ContentDetailsPageState extends State<ContentDetailsPage> { class _ContentDetailsPageState extends State<ContentDetailsPage> {
late TextEditingController _controller; late TextEditingController _controller;
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); // final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override @override
@ -91,14 +92,15 @@ class _ContentDetailsPageState extends State<ContentDetailsPage> {
), ),
bottomNavigationBar: PloneBottom( bottomNavigationBar: PloneBottom(
border: _controller.text.isEmpty, border: _controller.text.isEmpty,
opacity: _controller.text.isNotEmpty ? 1 : 0.4, opacity: _controller.text.isEmpty ? 1 : 0.4,
onTap: () async { onTap: () async {
// print(_controller.text);
BaseModel res = BaseModel res =
await apiClient.request(API.app.addTag, data: {'tag': _controller.text}); await apiClient.request(API.app.addTag, data: {'tag': _controller.text});
if (res.code == 0) { if (res.code == 0) {
setState(() {}); setState(() {});
widget.ploneBack(_controller.text); widget.ploneBack(_controller.text);
userProvider.updateUserInfo(); UserTool.userProvider.updateUserInfo();
Get.back(); Get.back();
} else { } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);

@ -81,6 +81,7 @@ dependencies:
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
#刷新组件 #刷新组件
flutter_easyrefresh: ^2.2.1 flutter_easyrefresh: ^2.2.1
# flutter_gen_runner: ^4.3.0,
# # jdk # # jdk
@ -92,25 +93,21 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
# test: ^1.21.4 # test: ^1.21.4
#导入包整理 #导入包整理
import_sorter: ^4.5.1 import_sorter: ^4.5.1
hive_generator: ^1.1.0 hive_generator: ^1.1.0
#model自动生成 #model自动生成
json_serializable: ^6.1.3 json_serializable: ^6.1.3
build_runner: ^2.0.2 build_runner: ^2.0.2
yaml: ^3.1.0 yaml: ^3.1.0
pub_semver: ^2.1.0 pub_semver: ^2.1.0
flutter_gen_runner: ^4.1.3 flutter_gen_runner: ^4.3.0
flutter_lints: ^2.0.0 flutter_lints: ^2.0.0
# patgh: ^1.8.1 # patgh: ^1.8.1
#脚本工具 # 脚本工具
grinder: ^0.9.1 grinder: ^0.9.1
flutter_native_splash: ^1.1.8+4 flutter_native_splash: ^1.1.8+4
@ -129,5 +126,5 @@ flutter:
- assets/ - assets/
- assets/icons/ - assets/icons/
- assets/images/ - assets/images/
# - assets/data/ # - assets/data/

Loading…
Cancel
Save