增加无网拦截

This commit is contained in:
YangYuhao 2023-07-10 09:25:10 +08:00
parent 998090ac78
commit d7679f5587
27 changed files with 193 additions and 130 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -30,7 +30,7 @@ class AboutappPage extends StatelessWidget {
), ),
child: Scaffold( child: Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
appBar: MyAppBar(centerTitle: '关于圈子',), appBar: const MyAppBar(centerTitle: '关于圈子',),
body: Scaffold( body: Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
// Replace with your desired color // Replace with your desired color
@ -105,11 +105,11 @@ class AboutappPage extends StatelessWidget {
Text( Text(
'用户协议', '用户协议',
style: TextStyle( style: TextStyle(
color: Color(0xFFF7FAFA), color: const Color(0xFFF7FAFA),
fontSize: 16.sp, fontSize: 16.sp,
), ),
), ),
Spacer(), const Spacer(),
Image( Image(
image: AssetImage(getHomeImage("icon_in")), image: AssetImage(getHomeImage("icon_in")),
width: 24.sp, width: 24.sp,
@ -127,14 +127,14 @@ class AboutappPage extends StatelessWidget {
}, },
child: Row( child: Row(
children: [ children: [
Text( const Text(
'隐私政策', '隐私政策',
style: TextStyle( style: TextStyle(
color: Color(0xFFF7FAFA), color: Color(0xFFF7FAFA),
fontSize: 16, fontSize: 16,
), ),
), ),
Spacer(), const Spacer(),
Image( Image(
image: AssetImage(getHomeImage("icon_in")), image: AssetImage(getHomeImage("icon_in")),
width: 24.sp, width: 24.sp,
@ -155,11 +155,11 @@ class AboutappPage extends StatelessWidget {
Text( Text(
'版本更新', '版本更新',
style: TextStyle( style: TextStyle(
color: Color(0xFFF7FAFA), color: const Color(0xFFF7FAFA),
fontSize: 16.sp, fontSize: 16.sp,
), ),
), ),
Spacer(), const Spacer(),
Container( Container(
width: 6.sp, width: 6.sp,
height: 5.sp, height: 5.sp,
@ -172,11 +172,11 @@ class AboutappPage extends StatelessWidget {
Text( Text(
logic.version, logic.version,
style: TextStyle( style: TextStyle(
color: Color(0xFFB7BECC), color: const Color(0xFFB7BECC),
fontSize: 12.sp, fontSize: 12.sp,
), ),
), ),
SizedBox(width: 8), SizedBox(width: 8.sp),
Image( Image(
image: AssetImage(getHomeImage("icon_in")), image: AssetImage(getHomeImage("icon_in")),
width: 24.sp, width: 24.sp,

View File

@ -6,12 +6,28 @@ import 'package:circle_app/util/util.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../network/api.dart'; import '../../../network/api.dart';
import '../../../util/SharedPreferencesHelper.dart'; import '../../../util/SharedPreferencesHelper.dart';
import 'state.dart'; import 'state.dart';
class LoginLogic extends GetxController { class LoginLogic extends GetxController {
@override
void onInit() async{
// TODO: implement onInit
super.onInit();
SharedPreferences sharedPreferences =await SharedPreferences.getInstance();
String loginPhone = await sharedPreferences.getString(SharedPreferencesHelper.LOGINPHONE)??"";
print(loginPhone);
phoneEditingController.text = loginPhone;
if (GetUtils.isPhoneNumber(loginPhone)&& loginPhone.length==11) {
isPhoto = true;
}
update();
}
bool isPhoto = false;
final LoginState state = LoginState(); final LoginState state = LoginState();
TextEditingController phoneEditingController = TextEditingController(); TextEditingController phoneEditingController = TextEditingController();
TextEditingController codeEditingController = TextEditingController(); TextEditingController codeEditingController = TextEditingController();
@ -24,8 +40,21 @@ class LoginLogic extends GetxController {
starDownTimer() { starDownTimer() {
if (sendCodeBtn == false && seconds == 60) { if (sendCodeBtn == false && seconds == 60) {
getCode(); getCode();
}
}
Future<void> getCode() async {
var data = await DioManager.instance.post(url: Api.sendCode, params: {"phone": phoneEditingController.text});
var bean = BaseResponse<Data>.fromJson(data, (data) => Data.fromJson(data));
showToast(bean.msg);
if(bean.code==200){
if(kDebugMode){
codeEditingController.text = bean.data!.code.toString();
update();
}
sendCodeBtn = true; sendCodeBtn = true;
t = Timer.periodic(Duration(milliseconds: 1000), (timer) { t = Timer.periodic(const Duration(milliseconds: 1000), (timer) {
seconds--; seconds--;
if (seconds == 0) { if (seconds == 0) {
t?.cancel(); // t?.cancel(); //
@ -35,18 +64,7 @@ class LoginLogic extends GetxController {
update(); update();
}); });
} }
}
Future<void> getCode() async {
var data = await DioManager.instance.post(url: Api.sendCode, params: {"phone": phoneEditingController.text});
var bean = BaseResponse<Data>.fromJson(data, (data) => Data.fromJson(data));
showToast(bean.msg);
if(kDebugMode){
if(bean.code==200){
codeEditingController.text = bean.data!.code.toString();
update();
}
}
} }
@override @override
@ -69,6 +87,7 @@ class LoginLogic extends GetxController {
var bean = BaseResponse<LoginData>.fromJson(data, (data) => LoginData.fromJson(data)); var bean = BaseResponse<LoginData>.fromJson(data, (data) => LoginData.fromJson(data));
if (bean.code == 200) { if (bean.code == 200) {
SharedPreferencesHelper.getInstance().then((sharedPreferences) { SharedPreferencesHelper.getInstance().then((sharedPreferences) {
sharedPreferences.setString(SharedPreferencesHelper.LOGINPHONE, phoneEditingController.text);
sharedPreferences.setString(SharedPreferencesHelper.AUTHORIZATION,bean.data!.Authorization.toString()); sharedPreferences.setString(SharedPreferencesHelper.AUTHORIZATION,bean.data!.Authorization.toString());
}); });
@ -78,6 +97,7 @@ class LoginLogic extends GetxController {
return; return;
} else if (bean.code == 30002) { } else if (bean.code == 30002) {
SharedPreferencesHelper.getInstance().then((sharedPreferences) { SharedPreferencesHelper.getInstance().then((sharedPreferences) {
sharedPreferences.setString(SharedPreferencesHelper.LOGINPHONE, phoneEditingController.text);
sharedPreferences.setString(SharedPreferencesHelper.AUTHORIZATION,bean.data!.Authorization.toString()); sharedPreferences.setString(SharedPreferencesHelper.AUTHORIZATION,bean.data!.Authorization.toString());
}); });

View File

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:circle_app/util/util.dart'; import 'package:circle_app/util/util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -13,7 +15,7 @@ class LoginPage extends StatelessWidget {
final state = Get final state = Get
.find<LoginLogic>() .find<LoginLogic>()
.state; .state;
bool isPhoto = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -57,9 +59,9 @@ class LoginPage extends StatelessWidget {
child: TextField( child: TextField(
onChanged: (msg){ onChanged: (msg){
if (GetUtils.isPhoneNumber(msg)&& msg.length==11) { if (GetUtils.isPhoneNumber(msg)&& msg.length==11) {
isPhoto = true; logic.isPhoto = true;
}else{ }else{
isPhoto = false; logic.isPhoto = false;
} }
logic.update(); logic.update();
}, },
@ -129,7 +131,7 @@ class LoginPage extends StatelessWidget {
right: 0, right: 0,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
if(isPhoto){ if(logic.isPhoto){
logic.starDownTimer(); logic.starDownTimer();
} }
}, },
@ -138,7 +140,7 @@ class LoginPage extends StatelessWidget {
width: 76.sp, width: 76.sp,
height: 29.sp, height: 29.sp,
decoration: BoxDecoration( decoration: BoxDecoration(
color:isPhoto ? Color(0xFF21BEAB) : Colors.white30, color:logic.isPhoto ? Color(0xFF21BEAB) : Colors.white30,
borderRadius: BorderRadius.circular( borderRadius: BorderRadius.circular(
29.sp / 2) 29.sp / 2)
), ),

View File

@ -1,4 +1,3 @@
import 'dart:math';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:circle_app/router/app_routers.dart'; import 'package:circle_app/router/app_routers.dart';
@ -26,8 +25,9 @@ class MinefragmentPage extends StatelessWidget {
.padding .padding
.top; .top;
return GetBuilder<MinefragmentLogic>(builder: (logic) { return GetBuilder<MinefragmentLogic>(
return Scaffold( builder: (logic) {
return Scaffold(
body: Container( body: Container(
width: Get.width, width: Get.width,
height: Get.height, height: Get.height,
@ -63,10 +63,8 @@ class MinefragmentPage extends StatelessWidget {
} }
Widget _CircleLiveView(MinefragmentLogic logic) { Widget _CircleLiveView(MinefragmentLogic logic) {
return Container( return Column(
child: Column( children: [_CircleItemView(logic), _HelpItemView(), _SetUpItemView()],
children: [_CircleItemView(logic), _HelpItemView(), _SetUpItemView()],
),
); );
} }
@ -91,7 +89,7 @@ class MinefragmentPage extends StatelessWidget {
height: 24.sp, height: 24.sp,
), ),
SizedBox(width: 10.sp), SizedBox(width: 10.sp),
Text( const Text(
"设置", "设置",
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
@ -132,7 +130,7 @@ class MinefragmentPage extends StatelessWidget {
height: 24.sp, height: 24.sp,
), ),
SizedBox(width: 10.sp), SizedBox(width: 10.sp),
Text( const Text(
"帮助与反馈", "帮助与反馈",
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
@ -172,7 +170,7 @@ class MinefragmentPage extends StatelessWidget {
height: 24.sp, height: 24.sp,
), ),
SizedBox(width: 10.sp), SizedBox(width: 10.sp),
Text( const Text(
"我的圈子", "我的圈子",
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
@ -182,7 +180,7 @@ class MinefragmentPage extends StatelessWidget {
children: [ children: [
Text( Text(
logic.JoinedCircle, logic.JoinedCircle,
style: TextStyle(color: Colors.white30), style: const TextStyle(color: Colors.white30),
), ),
Image( Image(
image: AssetImage(getHomeImage("icon_in")), image: AssetImage(getHomeImage("icon_in")),
@ -211,34 +209,32 @@ class MinefragmentPage extends StatelessWidget {
onTap: () { onTap: () {
Get.toNamed(AppRoutes.FriendsActivity); Get.toNamed(AppRoutes.FriendsActivity);
}, },
child: Container( child: Column(
child: Column( mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ Text(
Text( logic.like_count.toString(),
logic.like_count.toString(), style: TextStyle(
style: TextStyle( color: Colors.white,
color: Colors.white, fontSize: 16.sp,
fontSize: 16.sp, ),
), ),
), SizedBox(height: 4.sp),
SizedBox(height: 4.sp), Text(
Text( "我喜欢的",
"我喜欢的", style: TextStyle(
style: TextStyle( shadows: const [
shadows: [ Shadow(
Shadow( color: Color(0x99FF00F8),
color: Color(0x99FF00F8), offset: Offset(2, 2),
offset: Offset(2, 2), blurRadius: 3,
blurRadius: 3, ),
), ],
], color: const Color.fromARGB(255, 247, 250, 250),
color: Color.fromARGB(255, 247, 250, 250), fontSize: 16.sp,
fontSize: 16.sp, ),
), ),
), ],
],
),
), ),
), ),
GestureDetector( GestureDetector(
@ -260,13 +256,11 @@ class MinefragmentPage extends StatelessWidget {
children: [ children: [
Row( Row(
children: [ children: [
Container( Text(
child: Text( logic.like_me_count.toString(),
logic.like_me_count.toString(), style: TextStyle(
style: TextStyle( color: Colors.white,
color: Colors.white, fontSize: 16.sp,
fontSize: 16.sp,
),
), ),
), ),
], ],
@ -278,14 +272,14 @@ class MinefragmentPage extends StatelessWidget {
Text( Text(
"喜欢我的", "喜欢我的",
style: TextStyle( style: TextStyle(
shadows: [ shadows: const [
Shadow( Shadow(
color: Color(0x99FF00F8), color: Color(0x99FF00F8),
offset: Offset(2, 2), offset: Offset(2, 2),
blurRadius: 3, blurRadius: 3,
), ),
], ],
color: Color.fromARGB(255, 247, 250, 250), color: const Color.fromARGB(255, 247, 250, 250),
fontSize: 16.sp, fontSize: 16.sp,
), ),
), ),
@ -295,8 +289,8 @@ class MinefragmentPage extends StatelessWidget {
right: 0.sp, right: 0.sp,
top: 15.sp, top: 15.sp,
child: Text( child: Text(
logic.like_me_count_new>0 ? "+"+logic.like_me_count_new.toString():"", logic.like_me_count_new>0 ? "+${logic.like_me_count_new}":"",
style: TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)), style: const TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)),
), ),
) )
], ],
@ -320,32 +314,30 @@ class MinefragmentPage extends StatelessWidget {
children: [ children: [
Row( Row(
children: [ children: [
Container( Text(
child: Text( logic.recent_visit_count.toString(),
logic.recent_visit_count.toString(), style: TextStyle(
style: TextStyle( color: Colors.white,
color: Colors.white, fontSize: 16.sp,
fontSize: 16.sp, ),
),
),
), ),
], ],
), ),
Container( SizedBox(
height: 4.sp, height: 4.sp,
width: 80.sp, width: 80.sp,
), ),
Text( Text(
"最近来访", "最近来访",
style: TextStyle( style: TextStyle(
shadows: [ shadows: const [
Shadow( Shadow(
color: Color(0x99FF00F8), color: Color(0x99FF00F8),
offset: Offset(2, 2), offset: Offset(2, 2),
blurRadius: 3, blurRadius: 3,
), ),
], ],
color: Color.fromARGB(255, 247, 250, 250), color: const Color.fromARGB(255, 247, 250, 250),
fontSize: 16.sp, fontSize: 16.sp,
), ),
), ),
@ -355,8 +347,8 @@ class MinefragmentPage extends StatelessWidget {
right: 0.sp, right: 0.sp,
top: 15.sp, top: 15.sp,
child: Text( child: Text(
logic.recent_visit_count_new>0 ? "+"+logic.recent_visit_count_new.toString():"", logic.recent_visit_count_new>0 ? "+${logic.recent_visit_count_new}":"",
style: TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)), style: const TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)),
), ),
) )
], ],
@ -375,7 +367,7 @@ class MinefragmentPage extends StatelessWidget {
await Get.toNamed(AppRoutes.UserInfoActivity, arguments: ""); await Get.toNamed(AppRoutes.UserInfoActivity, arguments: "");
logic.onInit(); logic.onInit();
}, },
child: Container( child: SizedBox(
width: Get.width, width: Get.width,
height: 65.sp, height: 65.sp,
child: Row( child: Row(
@ -440,7 +432,7 @@ class MinefragmentPage extends StatelessWidget {
} }
}, },
child:logic.userInfoBean==null ? Container( child:logic.userInfoBean==null ? SizedBox(
width: 63.sp, width: 63.sp,
height: 63.sp, height: 63.sp,
): CachedNetworkImage( ): CachedNetworkImage(
@ -464,7 +456,7 @@ class MinefragmentPage extends StatelessWidget {
Text( Text(
logic.name, logic.name,
style: TextStyle( style: TextStyle(
color: Color.fromRGBO(247, 250, 250, 1.0), color: const Color.fromRGBO(247, 250, 250, 1.0),
fontSize: 16.sp, fontSize: 16.sp,
), ),
), ),
@ -473,7 +465,7 @@ class MinefragmentPage extends StatelessWidget {
Text( Text(
logic.enterHomeInfoMsg, logic.enterHomeInfoMsg,
style: TextStyle( style: TextStyle(
color: Color.fromRGBO(247, 250, 250, 1.0), color: const Color.fromRGBO(247, 250, 250, 1.0),
fontSize: 16.sp, fontSize: 16.sp,
), ),
), ),
@ -495,7 +487,7 @@ class MinefragmentPage extends StatelessWidget {
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(17), borderRadius: BorderRadius.circular(17),
gradient: LinearGradient( gradient: const LinearGradient(
colors: [ colors: [
Color.fromRGBO(141, 255, 248, 1.0), Color.fromRGBO(141, 255, 248, 1.0),
Color.fromRGBO(181, 211, 255, 1.0), Color.fromRGBO(181, 211, 255, 1.0),

View File

@ -1,9 +1,6 @@
import 'dart:ffi';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:circle_app/app/circle/logic.dart';
import 'package:circle_app/app/circle/state.dart'; import 'package:circle_app/app/circle/state.dart';
import 'package:circle_app/app/circle/widgets/list_logic.dart';
import 'package:circle_app/app/circle/widgets/video_item.dart'; import 'package:circle_app/app/circle/widgets/video_item.dart';
import 'package:circle_app/app/userinfo/widgets/home_call_out_logic.dart'; import 'package:circle_app/app/userinfo/widgets/home_call_out_logic.dart';
import 'package:circle_app/router/app_routers.dart'; import 'package:circle_app/router/app_routers.dart';

View File

@ -1,11 +1,9 @@
import 'dart:ffi';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import '../../network/api.dart'; import '../../network/api.dart';
import '../../network/dio_manager.dart'; import '../../network/dio_manager.dart';
import '../../util/util.dart';
import 'state.dart'; import 'state.dart';
class VisitorlistLogic extends GetxController { class VisitorlistLogic extends GetxController {

View File

@ -1,5 +1,4 @@
import 'package:circle_app/app/home/binding.dart';
import 'package:circle_app/app/home/view.dart';
import 'package:circle_app/app/splash/binding.dart'; import 'package:circle_app/app/splash/binding.dart';
import 'package:circle_app/router/app_pages.dart'; import 'package:circle_app/router/app_pages.dart';
import 'package:circle_app/router/app_routers.dart'; import 'package:circle_app/router/app_routers.dart';

View File

@ -6,6 +6,7 @@ import 'package:dio/dio.dart';
import '../util/device.dart'; import '../util/device.dart';
import 'api.dart'; import 'api.dart';
import 'package:connectivity/connectivity.dart';
const String baseUrl = Api.baseUrl; const String baseUrl = Api.baseUrl;
@ -43,6 +44,7 @@ class DioManager {
receiveTimeout: Duration(seconds: 30000000000), receiveTimeout: Duration(seconds: 30000000000),
)); ));
_dio!.interceptors.add(LogInterceptor(responseBody: true)); _dio!.interceptors.add(LogInterceptor(responseBody: true));
// _dio!.interceptors.add(ConnectivityInterceptor());
} }
Future download(String urlPath,String savePath,ProgressCallback progressCallback)async{ Future download(String urlPath,String savePath,ProgressCallback progressCallback)async{
@ -153,6 +155,13 @@ class DioManager {
DioMethod.delete: 'delete', DioMethod.delete: 'delete',
DioMethod.put: 'put' DioMethod.put: 'put'
}; };
var connectivityResult = await Connectivity().checkConnectivity();
if(connectivityResult == ConnectivityResult.none){
// showToast("");
return {'code': 404, 'msg': '请检查网络连接是否正常'};
}
try { try {
Response response; Response response;
@ -308,6 +317,22 @@ class BaseResponse<T> {
} }
class ConnectivityInterceptor extends Interceptor {
@override
Future<void> onRequest(
RequestOptions options, RequestInterceptorHandler handler) async {
if (!await isInternetAvailable()) {
showToast("请检查网络连接是否正常");
}
return handler.next(options);
}
Future<bool> isInternetAvailable() async {
var connectivityResult = await Connectivity().checkConnectivity();
return connectivityResult != ConnectivityResult.none;
}
}
class QnTokenData { class QnTokenData {
final String token; final String token;

View File

@ -11,6 +11,9 @@ class SharedPreferencesHelper {
static const AVATAR = 'avatar'; static const AVATAR = 'avatar';
static const NAME = 'name'; static const NAME = 'name';
static const LOGINPHONE = 'loginPhone';
static SharedPreferencesHelper? _instance; static SharedPreferencesHelper? _instance;
static SharedPreferences? _preferences; static SharedPreferences? _preferences;
@ -65,4 +68,5 @@ class SharedPreferencesHelper {
final prefs = preferences; final prefs = preferences;
prefs?.clear(); prefs?.clear();
} }
} }

View File

@ -14,9 +14,8 @@ import 'package:video_compress/video_compress.dart';
import 'SharedPreferencesHelper.dart'; import 'SharedPreferencesHelper.dart';
class Util { class Util {}
}
// //
String getBaseImage(String image) { String getBaseImage(String image) {
return '${Values.base_images}${image}.png'; return '${Values.base_images}${image}.png';
@ -50,8 +49,6 @@ String getCircleImage(String image) {
return '${Values.circle_images}${image}.png'; return '${Values.circle_images}${image}.png';
} }
/// msg: /// msg:
showToast(String msg) { showToast(String msg) {
Fluttertoast.showToast( Fluttertoast.showToast(
@ -61,17 +58,23 @@ showToast(String msg) {
timeInSecForIosWeb: 1, timeInSecForIosWeb: 1,
backgroundColor: Colors.black54, backgroundColor: Colors.black54,
textColor: Colors.white, textColor: Colors.white,
fontSize: 16.0 fontSize: 16.0);
);
} }
loaddingWidget(bool isMore) { loaddingWidget(bool isMore) {
return Container( return Container(
alignment: Alignment.center, alignment: Alignment.center,
child: isMore ? const CircularProgressIndicator(color: Color(0xFF07FAFB),) : Container( child: isMore
margin:EdgeInsets.only(top: 4.sp,bottom: 4.sp), ? const CircularProgressIndicator(
child: Text('--到底了--',style: TextStyle(color: Colors.white,fontSize: 13.sp), color: Color(0xFF07FAFB),
),), )
: Container(
margin: EdgeInsets.only(top: 4.sp, bottom: 4.sp),
child: Text(
'--到底了--',
style: TextStyle(color: Colors.white, fontSize: 13.sp),
),
),
); );
} }
@ -81,9 +84,17 @@ noResultWidget() {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Image.asset(getBaseImage('no_result'),width: 200.sp,), Image.asset(
SizedBox(height: 8.sp,), getBaseImage('no_result'),
Text('正在等待被填充~',style: TextStyle(color: Color(0xffdbdbdb),fontSize: 15.sp),), width: 200.sp,
),
SizedBox(
height: 8.sp,
),
Text(
'正在等待被填充~',
style: TextStyle(color: Color(0xffdbdbdb), fontSize: 15.sp),
),
], ],
), ),
); );
@ -95,11 +106,12 @@ double calculateTextHeight(String value, fontSize, FontWeight fontWeight,
value = filterText(value); value = filterText(value);
TextPainter painter = TextPainter( TextPainter painter = TextPainter(
///AUTOlocale的时候 ///AUTOlocale的时候
locale: WidgetsBinding.instance!.window.locale, locale: WidgetsBinding.instance!.window.locale,
maxLines: maxLines, maxLines: maxLines,
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
textScaleFactor: 1, // textScaleFactor: 1,
//
text: TextSpan( text: TextSpan(
text: value, text: value,
style: TextStyle( style: TextStyle(
@ -121,7 +133,6 @@ String filterText(String text) {
return text; return text;
} }
String convertToTenThousand(int number) { String convertToTenThousand(int number) {
if (number >= 10000) { if (number >= 10000) {
double result = number / 10000; double result = number / 10000;
@ -130,15 +141,19 @@ String convertToTenThousand(int number) {
return number.toString(); return number.toString();
} }
} }
pushLoginPage() async{
pushLoginPage() async {
logoutIM(); logoutIM();
SharedPreferencesHelper.getInstance().then((sharedPreferences) { SharedPreferencesHelper.getInstance().then((sharedPreferences) {
String loginPhone = sharedPreferences.getString(SharedPreferencesHelper.LOGINPHONE);
print(loginPhone);
sharedPreferences.clear(); sharedPreferences.clear();
sharedPreferences.setString(SharedPreferencesHelper.LOGINPHONE, loginPhone);
}); });
Get.offAllNamed(AppRoutes.Login); Get.offAllNamed(AppRoutes.Login);
} }
String filterSensitiveWords(String input, List<String> sensitiveWords) { String filterSensitiveWords(String input, List<String> sensitiveWords) {
String filteredString = input; String filteredString = input;
for (String word in sensitiveWords) { for (String word in sensitiveWords) {
@ -148,9 +163,8 @@ String filterSensitiveWords(String input, List<String> sensitiveWords) {
return filteredString; return filteredString;
} }
String getAgeCOntent (int gender,int age,int role,int orientation){ String getAgeCOntent(int gender, int age, int role, int orientation) {
return "${getGenderContent(gender)}.${age}.${getRoleContent(role)}.${getOrientationContent(orientation)}"; return "${getGenderContent(gender)}.${age}.${getRoleContent(role)}.${getOrientationContent(orientation)}";
} }
String getGenderContent(int number) { String getGenderContent(int number) {
@ -171,6 +185,7 @@ String getGenderContent(int number) {
return ""; return "";
} }
} }
String getOrientationContent(int number) { String getOrientationContent(int number) {
switch (number) { switch (number) {
case 1: case 1:
@ -191,6 +206,7 @@ String getOrientationContent(int number) {
return ""; return "";
} }
} }
String getRoleContent(int number) { String getRoleContent(int number) {
switch (number) { switch (number) {
case 1: case 1:
@ -210,14 +226,15 @@ String getRoleContent(int number) {
typedef void MyCallback(String path); typedef void MyCallback(String path);
Future<void> compressVideo(String inputPath, String outputPath,MyCallback myCallback) async { Future<void> compressVideo(
String inputPath, String outputPath, MyCallback myCallback) async {
final info = await VideoCompress.compressVideo( final info = await VideoCompress.compressVideo(
inputPath, inputPath,
quality: VideoQuality.MediumQuality, quality: VideoQuality.MediumQuality,
deleteOrigin: false, deleteOrigin: false,
); );
if (info != null&&null!=info.path) { if (info != null && null != info.path) {
print(info.path); print(info.path);
myCallback(info.path!); myCallback(info.path!);
} else { } else {
@ -225,7 +242,6 @@ Future<void> compressVideo(String inputPath, String outputPath,MyCallback myCall
} }
} }
// //
Future<String> getApplicationDocumentsDirectoryPath() async { Future<String> getApplicationDocumentsDirectoryPath() async {
final directory = await getApplicationDocumentsDirectory(); final directory = await getApplicationDocumentsDirectory();
@ -249,14 +265,21 @@ Future<String> getLibraryDirectoryPath() async {
final directory = await getLibraryDirectory(); final directory = await getLibraryDirectory();
return directory.path; return directory.path;
} }
// //
navigateToUserAgreement(){ navigateToUserAgreement() {
Get.toNamed(AppRoutes.WebViewActivity,arguments: {'title':"用户协议","url":"https://docs.qq.com/doc/DZVV1SkttZGlPUW1H"}); Get.toNamed(AppRoutes.WebViewActivity, arguments: {
'title': "用户协议",
"url": "https://docs.qq.com/doc/DZVV1SkttZGlPUW1H"
});
} }
// //
navigateToPrivacyPolicy(){ navigateToPrivacyPolicy() {
Get.toNamed(AppRoutes.WebViewActivity,arguments: {'title':"隐私协议","url":"https://docs.qq.com/doc/DZXhvcXV6b1RNTUx1"}); Get.toNamed(AppRoutes.WebViewActivity, arguments: {
'title': "隐私协议",
"url": "https://docs.qq.com/doc/DZXhvcXV6b1RNTUx1"
});
} }
// //

View File

@ -86,6 +86,9 @@ dependencies:
cached_network_image: ^3.2.3 cached_network_image: ^3.2.3
#安装apk #安装apk
flutter_install_app: 1.3.0 flutter_install_app: 1.3.0
#网络拦截
connectivity: ^3.0.6