diff --git a/circle_app/android/app/src/main/ic_launcher-playstore.png b/circle_app/android/app/src/main/ic_launcher-playstore.png index 62da4e7..fbe15f8 100644 Binary files a/circle_app/android/app/src/main/ic_launcher-playstore.png and b/circle_app/android/app/src/main/ic_launcher-playstore.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index 6edbca4..8bd5a6b 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png index 0caf2df..0d51dad 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png and b/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png index bbdcc18..9b7a659 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and b/circle_app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index d85abdd..baac193 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png index 9cf1522..2662530 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png and b/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png index 88e6048..9461c68 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and b/circle_app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index aa25024..3fcfd44 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png index 23a55b2..0791ee2 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png and b/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png index dd1ffa2..24eae06 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and b/circle_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 26f8201..5b179e0 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png index 46ee5cc..c1c5703 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png and b/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png index 6a800de..49f166a 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and b/circle_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 5963223..2208fde 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png index 68ae16a..9845e87 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png and b/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png index 6587c14..0d75056 100644 Binary files a/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and b/circle_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/circle_app/lib/app/aboutapp/view.dart b/circle_app/lib/app/aboutapp/view.dart index c563cd3..504ffd8 100644 --- a/circle_app/lib/app/aboutapp/view.dart +++ b/circle_app/lib/app/aboutapp/view.dart @@ -30,7 +30,7 @@ class AboutappPage extends StatelessWidget { ), child: Scaffold( backgroundColor: Colors.transparent, - appBar: MyAppBar(centerTitle: '关于圈子',), + appBar: const MyAppBar(centerTitle: '关于圈子',), body: Scaffold( backgroundColor: Colors.transparent, // Replace with your desired color @@ -105,11 +105,11 @@ class AboutappPage extends StatelessWidget { Text( '用户协议', style: TextStyle( - color: Color(0xFFF7FAFA), + color: const Color(0xFFF7FAFA), fontSize: 16.sp, ), ), - Spacer(), + const Spacer(), Image( image: AssetImage(getHomeImage("icon_in")), width: 24.sp, @@ -127,14 +127,14 @@ class AboutappPage extends StatelessWidget { }, child: Row( children: [ - Text( + const Text( '隐私政策', style: TextStyle( color: Color(0xFFF7FAFA), fontSize: 16, ), ), - Spacer(), + const Spacer(), Image( image: AssetImage(getHomeImage("icon_in")), width: 24.sp, @@ -155,11 +155,11 @@ class AboutappPage extends StatelessWidget { Text( '版本更新', style: TextStyle( - color: Color(0xFFF7FAFA), + color: const Color(0xFFF7FAFA), fontSize: 16.sp, ), ), - Spacer(), + const Spacer(), Container( width: 6.sp, height: 5.sp, @@ -172,11 +172,11 @@ class AboutappPage extends StatelessWidget { Text( logic.version, style: TextStyle( - color: Color(0xFFB7BECC), + color: const Color(0xFFB7BECC), fontSize: 12.sp, ), ), - SizedBox(width: 8), + SizedBox(width: 8.sp), Image( image: AssetImage(getHomeImage("icon_in")), width: 24.sp, diff --git a/circle_app/lib/app/login/login/logic.dart b/circle_app/lib/app/login/login/logic.dart index f0dbb23..0d656af 100644 --- a/circle_app/lib/app/login/login/logic.dart +++ b/circle_app/lib/app/login/login/logic.dart @@ -6,12 +6,28 @@ import 'package:circle_app/util/util.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:get/get.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../../../network/api.dart'; import '../../../util/SharedPreferencesHelper.dart'; import 'state.dart'; 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(); TextEditingController phoneEditingController = TextEditingController(); TextEditingController codeEditingController = TextEditingController(); @@ -24,8 +40,21 @@ class LoginLogic extends GetxController { starDownTimer() { if (sendCodeBtn == false && seconds == 60) { getCode(); + + } + } + + Future getCode() async { + var data = await DioManager.instance.post(url: Api.sendCode, params: {"phone": phoneEditingController.text}); + var bean = BaseResponse.fromJson(data, (data) => Data.fromJson(data)); + showToast(bean.msg); + if(bean.code==200){ + if(kDebugMode){ + codeEditingController.text = bean.data!.code.toString(); + update(); + } sendCodeBtn = true; - t = Timer.periodic(Duration(milliseconds: 1000), (timer) { + t = Timer.periodic(const Duration(milliseconds: 1000), (timer) { seconds--; if (seconds == 0) { t?.cancel(); //清除 @@ -35,18 +64,7 @@ class LoginLogic extends GetxController { update(); }); } - } - Future getCode() async { - var data = await DioManager.instance.post(url: Api.sendCode, params: {"phone": phoneEditingController.text}); - var bean = BaseResponse.fromJson(data, (data) => Data.fromJson(data)); - showToast(bean.msg); - if(kDebugMode){ - if(bean.code==200){ - codeEditingController.text = bean.data!.code.toString(); - update(); - } - } } @override @@ -69,6 +87,7 @@ class LoginLogic extends GetxController { var bean = BaseResponse.fromJson(data, (data) => LoginData.fromJson(data)); if (bean.code == 200) { SharedPreferencesHelper.getInstance().then((sharedPreferences) { + sharedPreferences.setString(SharedPreferencesHelper.LOGINPHONE, phoneEditingController.text); sharedPreferences.setString(SharedPreferencesHelper.AUTHORIZATION,bean.data!.Authorization.toString()); }); @@ -78,6 +97,7 @@ class LoginLogic extends GetxController { return; } else if (bean.code == 30002) { SharedPreferencesHelper.getInstance().then((sharedPreferences) { + sharedPreferences.setString(SharedPreferencesHelper.LOGINPHONE, phoneEditingController.text); sharedPreferences.setString(SharedPreferencesHelper.AUTHORIZATION,bean.data!.Authorization.toString()); }); diff --git a/circle_app/lib/app/login/login/view.dart b/circle_app/lib/app/login/login/view.dart index 3fc619c..840e167 100644 --- a/circle_app/lib/app/login/login/view.dart +++ b/circle_app/lib/app/login/login/view.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:circle_app/util/util.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -13,7 +15,7 @@ class LoginPage extends StatelessWidget { final state = Get .find() .state; - bool isPhoto = false; + @override Widget build(BuildContext context) { @@ -57,9 +59,9 @@ class LoginPage extends StatelessWidget { child: TextField( onChanged: (msg){ if (GetUtils.isPhoneNumber(msg)&& msg.length==11) { - isPhoto = true; + logic.isPhoto = true; }else{ - isPhoto = false; + logic.isPhoto = false; } logic.update(); }, @@ -129,7 +131,7 @@ class LoginPage extends StatelessWidget { right: 0, child: GestureDetector( onTap: () { - if(isPhoto){ + if(logic.isPhoto){ logic.starDownTimer(); } }, @@ -138,7 +140,7 @@ class LoginPage extends StatelessWidget { width: 76.sp, height: 29.sp, decoration: BoxDecoration( - color:isPhoto ? Color(0xFF21BEAB) : Colors.white30, + color:logic.isPhoto ? Color(0xFF21BEAB) : Colors.white30, borderRadius: BorderRadius.circular( 29.sp / 2) ), diff --git a/circle_app/lib/app/minefragment/view.dart b/circle_app/lib/app/minefragment/view.dart index cffa445..60eaf5a 100644 --- a/circle_app/lib/app/minefragment/view.dart +++ b/circle_app/lib/app/minefragment/view.dart @@ -1,4 +1,3 @@ -import 'dart:math'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:circle_app/router/app_routers.dart'; @@ -26,8 +25,9 @@ class MinefragmentPage extends StatelessWidget { .padding .top; - return GetBuilder(builder: (logic) { - return Scaffold( + return GetBuilder( + builder: (logic) { + return Scaffold( body: Container( width: Get.width, height: Get.height, @@ -63,10 +63,8 @@ class MinefragmentPage extends StatelessWidget { } Widget _CircleLiveView(MinefragmentLogic logic) { - return Container( - child: Column( - children: [_CircleItemView(logic), _HelpItemView(), _SetUpItemView()], - ), + return Column( + children: [_CircleItemView(logic), _HelpItemView(), _SetUpItemView()], ); } @@ -91,7 +89,7 @@ class MinefragmentPage extends StatelessWidget { height: 24.sp, ), SizedBox(width: 10.sp), - Text( + const Text( "设置", style: TextStyle(color: Colors.white), ), @@ -132,7 +130,7 @@ class MinefragmentPage extends StatelessWidget { height: 24.sp, ), SizedBox(width: 10.sp), - Text( + const Text( "帮助与反馈", style: TextStyle(color: Colors.white), ), @@ -172,7 +170,7 @@ class MinefragmentPage extends StatelessWidget { height: 24.sp, ), SizedBox(width: 10.sp), - Text( + const Text( "我的圈子", style: TextStyle(color: Colors.white), ), @@ -182,7 +180,7 @@ class MinefragmentPage extends StatelessWidget { children: [ Text( logic.JoinedCircle, - style: TextStyle(color: Colors.white30), + style: const TextStyle(color: Colors.white30), ), Image( image: AssetImage(getHomeImage("icon_in")), @@ -211,34 +209,32 @@ class MinefragmentPage extends StatelessWidget { onTap: () { Get.toNamed(AppRoutes.FriendsActivity); }, - child: Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - logic.like_count.toString(), - style: TextStyle( - color: Colors.white, - fontSize: 16.sp, - ), - ), - SizedBox(height: 4.sp), - Text( - "我喜欢的", - style: TextStyle( - shadows: [ - Shadow( - color: Color(0x99FF00F8), - offset: Offset(2, 2), - blurRadius: 3, - ), - ], - color: Color.fromARGB(255, 247, 250, 250), - fontSize: 16.sp, - ), - ), - ], - ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + logic.like_count.toString(), + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + ), + ), + SizedBox(height: 4.sp), + Text( + "我喜欢的", + style: TextStyle( + shadows: const [ + Shadow( + color: Color(0x99FF00F8), + offset: Offset(2, 2), + blurRadius: 3, + ), + ], + color: const Color.fromARGB(255, 247, 250, 250), + fontSize: 16.sp, + ), + ), + ], ), ), GestureDetector( @@ -260,13 +256,11 @@ class MinefragmentPage extends StatelessWidget { children: [ Row( children: [ - Container( - child: Text( - logic.like_me_count.toString(), - style: TextStyle( - color: Colors.white, - fontSize: 16.sp, - ), + Text( + logic.like_me_count.toString(), + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, ), ), ], @@ -278,14 +272,14 @@ class MinefragmentPage extends StatelessWidget { Text( "喜欢我的", style: TextStyle( - shadows: [ + shadows: const [ Shadow( color: Color(0x99FF00F8), offset: Offset(2, 2), blurRadius: 3, ), ], - color: Color.fromARGB(255, 247, 250, 250), + color: const Color.fromARGB(255, 247, 250, 250), fontSize: 16.sp, ), ), @@ -295,8 +289,8 @@ class MinefragmentPage extends StatelessWidget { right: 0.sp, top: 15.sp, child: Text( - logic.like_me_count_new>0 ? "+"+logic.like_me_count_new.toString():"", - style: TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)), + logic.like_me_count_new>0 ? "+${logic.like_me_count_new}":"", + style: const TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)), ), ) ], @@ -320,32 +314,30 @@ class MinefragmentPage extends StatelessWidget { children: [ Row( children: [ - Container( - child: Text( - logic.recent_visit_count.toString(), - style: TextStyle( - color: Colors.white, - fontSize: 16.sp, - ), - ), + Text( + logic.recent_visit_count.toString(), + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + ), ), ], ), - Container( + SizedBox( height: 4.sp, width: 80.sp, ), Text( "最近来访", style: TextStyle( - shadows: [ + shadows: const [ Shadow( color: Color(0x99FF00F8), offset: Offset(2, 2), blurRadius: 3, ), ], - color: Color.fromARGB(255, 247, 250, 250), + color: const Color.fromARGB(255, 247, 250, 250), fontSize: 16.sp, ), ), @@ -355,8 +347,8 @@ class MinefragmentPage extends StatelessWidget { right: 0.sp, top: 15.sp, child: Text( - logic.recent_visit_count_new>0 ? "+"+logic.recent_visit_count_new.toString():"", - style: TextStyle(color: Color.fromRGBO(0, 255, 210, 1.0)), + logic.recent_visit_count_new>0 ? "+${logic.recent_visit_count_new}":"", + 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: ""); logic.onInit(); }, - child: Container( + child: SizedBox( width: Get.width, height: 65.sp, child: Row( @@ -440,7 +432,7 @@ class MinefragmentPage extends StatelessWidget { } }, - child:logic.userInfoBean==null ? Container( + child:logic.userInfoBean==null ? SizedBox( width: 63.sp, height: 63.sp, ): CachedNetworkImage( @@ -464,7 +456,7 @@ class MinefragmentPage extends StatelessWidget { Text( logic.name, style: TextStyle( - color: Color.fromRGBO(247, 250, 250, 1.0), + color: const Color.fromRGBO(247, 250, 250, 1.0), fontSize: 16.sp, ), ), @@ -473,7 +465,7 @@ class MinefragmentPage extends StatelessWidget { Text( logic.enterHomeInfoMsg, style: TextStyle( - color: Color.fromRGBO(247, 250, 250, 1.0), + color: const Color.fromRGBO(247, 250, 250, 1.0), fontSize: 16.sp, ), ), @@ -495,7 +487,7 @@ class MinefragmentPage extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(17), - gradient: LinearGradient( + gradient: const LinearGradient( colors: [ Color.fromRGBO(141, 255, 248, 1.0), Color.fromRGBO(181, 211, 255, 1.0), diff --git a/circle_app/lib/app/userinfo/widgets/home_call_out.dart b/circle_app/lib/app/userinfo/widgets/home_call_out.dart index 67c6622..47f7a79 100644 --- a/circle_app/lib/app/userinfo/widgets/home_call_out.dart +++ b/circle_app/lib/app/userinfo/widgets/home_call_out.dart @@ -1,9 +1,6 @@ -import 'dart:ffi'; 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/widgets/list_logic.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/router/app_routers.dart'; diff --git a/circle_app/lib/app/visitorlist/logic.dart b/circle_app/lib/app/visitorlist/logic.dart index 3c09ce8..b1ab4a7 100644 --- a/circle_app/lib/app/visitorlist/logic.dart +++ b/circle_app/lib/app/visitorlist/logic.dart @@ -1,11 +1,9 @@ -import 'dart:ffi'; import 'package:get/get.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import '../../network/api.dart'; import '../../network/dio_manager.dart'; -import '../../util/util.dart'; import 'state.dart'; class VisitorlistLogic extends GetxController { diff --git a/circle_app/lib/main.dart b/circle_app/lib/main.dart index e78d5cf..8bf6280 100644 --- a/circle_app/lib/main.dart +++ b/circle_app/lib/main.dart @@ -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/router/app_pages.dart'; import 'package:circle_app/router/app_routers.dart'; diff --git a/circle_app/lib/network/dio_manager.dart b/circle_app/lib/network/dio_manager.dart index 33f991a..00ff189 100644 --- a/circle_app/lib/network/dio_manager.dart +++ b/circle_app/lib/network/dio_manager.dart @@ -6,6 +6,7 @@ import 'package:dio/dio.dart'; import '../util/device.dart'; import 'api.dart'; +import 'package:connectivity/connectivity.dart'; const String baseUrl = Api.baseUrl; @@ -43,6 +44,7 @@ class DioManager { receiveTimeout: Duration(seconds: 30000000000), )); _dio!.interceptors.add(LogInterceptor(responseBody: true)); + // _dio!.interceptors.add(ConnectivityInterceptor()); } Future download(String urlPath,String savePath,ProgressCallback progressCallback)async{ @@ -153,6 +155,13 @@ class DioManager { DioMethod.delete: 'delete', DioMethod.put: 'put' }; + var connectivityResult = await Connectivity().checkConnectivity(); + + if(connectivityResult == ConnectivityResult.none){ + // showToast(""); + return {'code': 404, 'msg': '请检查网络连接是否正常'}; + } + try { Response response; @@ -308,6 +317,22 @@ class BaseResponse { } +class ConnectivityInterceptor extends Interceptor { + @override + Future onRequest( + RequestOptions options, RequestInterceptorHandler handler) async { + if (!await isInternetAvailable()) { + showToast("请检查网络连接是否正常"); + } + return handler.next(options); + } + + Future isInternetAvailable() async { + var connectivityResult = await Connectivity().checkConnectivity(); + return connectivityResult != ConnectivityResult.none; + } +} + class QnTokenData { final String token; diff --git a/circle_app/lib/util/SharedPreferencesHelper.dart b/circle_app/lib/util/SharedPreferencesHelper.dart index e9c9919..8c5c5a8 100644 --- a/circle_app/lib/util/SharedPreferencesHelper.dart +++ b/circle_app/lib/util/SharedPreferencesHelper.dart @@ -11,6 +11,9 @@ class SharedPreferencesHelper { static const AVATAR = 'avatar'; static const NAME = 'name'; + static const LOGINPHONE = 'loginPhone'; + + static SharedPreferencesHelper? _instance; static SharedPreferences? _preferences; @@ -65,4 +68,5 @@ class SharedPreferencesHelper { final prefs = preferences; prefs?.clear(); } + } diff --git a/circle_app/lib/util/util.dart b/circle_app/lib/util/util.dart index 7b74cf8..73022f5 100644 --- a/circle_app/lib/util/util.dart +++ b/circle_app/lib/util/util.dart @@ -14,9 +14,8 @@ import 'package:video_compress/video_compress.dart'; import 'SharedPreferencesHelper.dart'; -class Util { +class Util {} -} //获取图片 String getBaseImage(String image) { return '${Values.base_images}${image}.png'; @@ -50,8 +49,6 @@ String getCircleImage(String image) { return '${Values.circle_images}${image}.png'; } - - ///弹窗文本提示 msg: 提示内容 showToast(String msg) { Fluttertoast.showToast( @@ -61,17 +58,23 @@ showToast(String msg) { timeInSecForIosWeb: 1, backgroundColor: Colors.black54, textColor: Colors.white, - fontSize: 16.0 - ); + fontSize: 16.0); } loaddingWidget(bool isMore) { return Container( alignment: Alignment.center, - child: isMore ? const CircularProgressIndicator(color: Color(0xFF07FAFB),) : Container( - margin:EdgeInsets.only(top: 4.sp,bottom: 4.sp), - child: Text('--到底了--',style: TextStyle(color: Colors.white,fontSize: 13.sp), - ),), + child: isMore + ? const CircularProgressIndicator( + 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( mainAxisAlignment: MainAxisAlignment.center, children: [ - Image.asset(getBaseImage('no_result'),width: 200.sp,), - SizedBox(height: 8.sp,), - Text('正在等待被填充~',style: TextStyle(color: Color(0xffdbdbdb),fontSize: 15.sp),), + Image.asset( + getBaseImage('no_result'), + 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); TextPainter painter = TextPainter( - ///AUTO:华为手机如果不指定locale的时候,该方法算出来的文字高度是比系统计算偏小的。 + ///AUTO:华为手机如果不指定locale的时候,该方法算出来的文字高度是比系统计算偏小的。 locale: WidgetsBinding.instance!.window.locale, maxLines: maxLines, textDirection: TextDirection.ltr, - textScaleFactor: 1, //字体缩放大小 + textScaleFactor: 1, + //字体缩放大小 text: TextSpan( text: value, style: TextStyle( @@ -121,7 +133,6 @@ String filterText(String text) { return text; } - String convertToTenThousand(int number) { if (number >= 10000) { double result = number / 10000; @@ -130,15 +141,19 @@ String convertToTenThousand(int number) { return number.toString(); } } -pushLoginPage() async{ + +pushLoginPage() async { logoutIM(); SharedPreferencesHelper.getInstance().then((sharedPreferences) { + String loginPhone = sharedPreferences.getString(SharedPreferencesHelper.LOGINPHONE); + print(loginPhone); sharedPreferences.clear(); + sharedPreferences.setString(SharedPreferencesHelper.LOGINPHONE, loginPhone); }); - Get.offAllNamed(AppRoutes.Login); } + String filterSensitiveWords(String input, List sensitiveWords) { String filteredString = input; for (String word in sensitiveWords) { @@ -148,9 +163,8 @@ String filterSensitiveWords(String input, List sensitiveWords) { return filteredString; } -String getAgeCOntent (int gender,int age,int role,int orientation){ - return "${getGenderContent(gender)}.${age}.${getRoleContent(role)}.${getOrientationContent(orientation)}"; - +String getAgeCOntent(int gender, int age, int role, int orientation) { + return "${getGenderContent(gender)}.${age}.${getRoleContent(role)}.${getOrientationContent(orientation)}"; } String getGenderContent(int number) { @@ -171,6 +185,7 @@ String getGenderContent(int number) { return ""; } } + String getOrientationContent(int number) { switch (number) { case 1: @@ -191,6 +206,7 @@ String getOrientationContent(int number) { return ""; } } + String getRoleContent(int number) { switch (number) { case 1: @@ -210,14 +226,15 @@ String getRoleContent(int number) { typedef void MyCallback(String path); -Future compressVideo(String inputPath, String outputPath,MyCallback myCallback) async { +Future compressVideo( + String inputPath, String outputPath, MyCallback myCallback) async { final info = await VideoCompress.compressVideo( inputPath, quality: VideoQuality.MediumQuality, deleteOrigin: false, ); - if (info != null&&null!=info.path) { + if (info != null && null != info.path) { print(info.path); myCallback(info.path!); } else { @@ -225,7 +242,6 @@ Future compressVideo(String inputPath, String outputPath,MyCallback myCall } } - // 获取应用程序的文档目录路径 Future getApplicationDocumentsDirectoryPath() async { final directory = await getApplicationDocumentsDirectory(); @@ -249,15 +265,22 @@ Future getLibraryDirectoryPath() async { final directory = await getLibraryDirectory(); return directory.path; } + //跳转到用户协议 -navigateToUserAgreement(){ - Get.toNamed(AppRoutes.WebViewActivity,arguments: {'title':"用户协议","url":"https://docs.qq.com/doc/DZVV1SkttZGlPUW1H"}); +navigateToUserAgreement() { + Get.toNamed(AppRoutes.WebViewActivity, arguments: { + 'title': "用户协议", + "url": "https://docs.qq.com/doc/DZVV1SkttZGlPUW1H" + }); } //跳转到隐私政策 -navigateToPrivacyPolicy(){ - Get.toNamed(AppRoutes.WebViewActivity,arguments: {'title':"隐私协议","url":"https://docs.qq.com/doc/DZXhvcXV6b1RNTUx1"}); +navigateToPrivacyPolicy() { + Get.toNamed(AppRoutes.WebViewActivity, arguments: { + 'title': "隐私协议", + "url": "https://docs.qq.com/doc/DZXhvcXV6b1RNTUx1" + }); } //发布内容规范 -//合伙人协议 \ No newline at end of file +//合伙人协议 diff --git a/circle_app/pubspec.yaml b/circle_app/pubspec.yaml index 7610c94..6aafbe2 100644 --- a/circle_app/pubspec.yaml +++ b/circle_app/pubspec.yaml @@ -86,6 +86,9 @@ dependencies: cached_network_image: ^3.2.3 #安装apk flutter_install_app: 1.3.0 + #网络拦截 + connectivity: ^3.0.6 +