소스 검색

1.优化启动速度

2.优化手机号一键登录
3.更换android图标
4.优化提现页面
tags/0.0.3+6
“yanghuaxuan” 3 년 전
부모
커밋
45f1be116d
13개의 변경된 파일259개의 추가작업 그리고 123개의 파일을 삭제
  1. +28
    -28
      example/android/app/build.gradle
  2. +1
    -1
      example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java
  3. BIN
     
  4. BIN
     
  5. BIN
     
  6. BIN
     
  7. BIN
     
  8. +2
    -1
      example/android/app/src/main/res/values/styles.xml
  9. +131
    -52
      lib/pages/home_page/home_page.dart
  10. +70
    -33
      lib/pages/launch_page/launch_page.dart
  11. +24
    -7
      lib/pages/withdraw_page/withdraw_page.dart
  12. +1
    -1
      lib/register.dart
  13. +2
    -0
      pubspec.yaml

+ 28
- 28
example/android/app/build.gradle 파일 보기

@@ -107,34 +107,34 @@ android {
}


// 应用信息配置
// productFlavors {
// // 智夜生活
// zhiying {
// applicationId "cn.zhios.zhiying"
// versionCode 22
// dimension "app"
// versionName '1.2.2'
// // 签名信息
// signingConfig signingConfigs.zhiying
// }
// }
//
// // 打包脚本
// android.applicationVariants.all { variant ->
// if (variant.buildType.name != "debug") {
// variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk")
// }
//
// variant.outputs.all { output ->
// def outputFile = output.outputFile
// if (outputFile != null && outputFile.name.endsWith('.apk')) {
// //这里修改apk文件名
// def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk"
// outputFileName = fileName
// }
// }
// }
//应用信息配置
productFlavors {
// 智夜生活
zhiying {
applicationId "cn.zhios.zhiying"
versionCode 23
dimension "app"
versionName '1.2.3'
// 签名信息
signingConfig signingConfigs.zhiying
}
}
// 打包脚本
android.applicationVariants.all { variant ->
if (variant.buildType.name != "debug") {
variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk")
}
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
//这里修改apk文件名
def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk"
outputFileName = fileName
}
}
}

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->


+ 1
- 1
example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java 파일 보기

@@ -90,7 +90,7 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN
Map map = new HashMap();
map.put("domain", "http://inapi.izhyin.cn/"); //"http://120.76.175.204:8989");
// map.put("domain", "http://192.168.0.113:5000");
map.put("master_id", "123456");
map.put("master_id", "963258");
map.put("secret_key", "123456");
// map.put("token", "123465");
return map;







+ 2
- 1
example/android/app/src/main/res/values/styles.xml 파일 보기

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
<style name="LaunchTheme" parent="Theme.AppCompat.DayNight.NoActionBar">

<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>


+ 131
- 52
lib/pages/home_page/home_page.dart 파일 보기

@@ -1,12 +1,15 @@
import 'dart:async';
import 'dart:convert' as convert;
import 'dart:convert';
import 'dart:io';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:connectivity/connectivity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:moblink/moblink.dart';
import 'package:mobpush_plugin/mobpush_custom_message.dart';
import 'package:mobpush_plugin/mobpush_notify_message.dart';
@@ -16,6 +19,7 @@ import 'package:zhiying_base_widget/dialog/global_dialog/activity_dialog/activit
import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/notification_setting_dialog/notification_setting_dialog.dart';
import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart';
import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_base_widget/utils/mob_push_util.dart';
import 'package:zhiying_comm/models/base/base_tab_model.dart';
@@ -28,6 +32,7 @@ import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_comm/util/event_util/login_success_event.dart';
import 'package:zhiying_comm/util/event_util/event_util.dart';
import 'package:zhiying_comm/util/event_util/log_out.dart';
import 'package:package_info/package_info.dart';

class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);
@@ -36,63 +41,107 @@ class HomePage extends StatefulWidget {
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
class _HomePageState extends State<HomePage> with WidgetsBindingObserver, TickerProviderStateMixin {
int _currentIndex = 0;
List<Map<String, dynamic>> _data = List();
static const EventChannel _eventChannel = const EventChannel('JAVA_TO_FLUTTER');
AnimationController animationController;
Animation<double> scaleAnimation;
Animation<double> opacityAnimation;
double opacity = 1.0;

bool initFinish = false;

double maxRatio = 5.0;

@override
void initState() {
WidgetsBinding.instance.addObserver(this);
String data = BaseSettingModel.setting.tab['data'];
try {
List list = convert.jsonDecode(data);
_data = list.map((item) {
return Map<String, dynamic>.from(item);
}).toList();
Logger.debug(_data);
} catch (error) {
Logger.error(error);
}
Constants.isShowIntellectDialog = false;
animationController = AnimationController(vsync: this, duration: Duration(milliseconds: 500));
CurvedAnimation curvedAnimation = CurvedAnimation(parent: animationController, curve: Curves.ease);
scaleAnimation = Tween<double>(begin: 1.0, end: maxRatio).animate(curvedAnimation);
opacityAnimation = Tween<double>(begin: 0.7, end: 0).animate(curvedAnimation);
animationController.addListener(() {
print(scaleAnimation.value);

if (scaleAnimation.value == maxRatio) {
// 动画结束后显示弹窗
_showPolicy();
setState(() {});
}
});

TaobaoAuth.initAuth(context);
///初始化一些数据
initAsync();

// 弹窗
_showPolicy();
///打开动画
Timer(Duration(milliseconds: 0), () {
animationController.forward();
});

Moblink.uploadPrivacyPermissionStatus(1, (bool success) {});
SharesdkPlugin.uploadPrivacyPermissionStatus(1, (bool success) {});
// 是安卓系统,Android场景还原的实现
/*if (defaultTargetPlatform == TargetPlatform.android) {
///打开动画
Timer(Duration(milliseconds: 1000), () {
initFinish = true;
setState(() {});
});

}*/
setState(() {});
super.initState();
}

//app后台杀死时候的还原
Moblink.restoreScene(_restore);
// 监听开始(传递监听到原生端,用户监听场景还原的数据回传回来)
_eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);
MobPushUtil.addPushReceiver();
EventUtil.instance.on<LoginSuccessEvent>().listen((event) async {
UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo;
var setting = await NativeUtil.getSetting();
String masterId = setting['master_id'];
Logger.log("我的Alias: " + masterId + "_" + userInfo?.userId);
if (!EmptyUtil.isEmpty(userInfo.userId) && !EmptyUtil.isEmpty(masterId)) {
MobPushUtil.setAlias(masterId + "_" + userInfo.userId);
///初始化各种监听
initAsync() async {
try {
WidgetsBinding.instance.addObserver(this);
String data = BaseSettingModel.setting.tab['data'];
try {
List list = convert.jsonDecode(data);
_data = list.map((item) {
return Map<String, dynamic>.from(item);
}).toList();
Logger.debug(_data);
} catch (error) {
Logger.error(error);
}
});
Constants.isShowIntellectDialog = false;

EventUtil.instance.on<LogOut>().listen((event) {
MobPushUtil.deleteAlias();
});
super.initState();
TaobaoAuth.initAuth(context);

Moblink.uploadPrivacyPermissionStatus(1, (bool success) {});
SharesdkPlugin.uploadPrivacyPermissionStatus(1, (bool success) {});
// 是安卓系统,Android场景还原的实现
/*if (defaultTargetPlatform == TargetPlatform.android) {

}*/

//app后台杀死时候的还原
Moblink.restoreScene(_restore);
// 监听开始(传递监听到原生端,用户监听场景还原的数据回传回来)
_eventChannel.receiveBroadcastStream().listen(_onEvent, onError: _onError);

MobPushUtil.addPushReceiver();
EventUtil.instance.on<LoginSuccessEvent>().listen((event) async {
UserInfoModel userInfo = UserInfoNotifier?.staitcUserInfo;
var setting = await NativeUtil.getSetting();
String masterId = setting['master_id'];
Logger.log("我的Alias: " + masterId + "_" + userInfo?.userId);
if (!EmptyUtil.isEmpty(userInfo.userId) && !EmptyUtil.isEmpty(masterId)) {
MobPushUtil.setAlias(masterId + "_" + userInfo.userId);
}
});

EventUtil.instance.on<LogOut>().listen((event) {
MobPushUtil.deleteAlias();
});
} catch (e, s) {
print(e);
print(s);
}
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
animationController.dispose();
super.dispose();
}

@@ -106,6 +155,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
@override
Widget build(BuildContext context) {
ScreenUtil.init(context, width: 750, height: 1334);

Logger.debug('home_page build');
List<Map<String, dynamic>> tabs = _data;
if (tabs == null || tabs.length == 0) {
@@ -120,13 +170,45 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
_currentIndex = 0;
}

return Scaffold(
body: IndexedStack(
index: _currentIndex,
children: contentWidgets,
),
//底部导航栏
bottomNavigationBar: createBottomNavigationBar(tabs),
// return Scaffold(
// body: IndexedStack(
// index: _currentIndex,
// children: contentWidgets,
// ),
// //底部导航栏
// bottomNavigationBar: createBottomNavigationBar(tabs),
// );
return Stack(
alignment: Alignment.topCenter,
children: <Widget>[
Scaffold(
body: IndexedStack(
index: _currentIndex,
children: contentWidgets,
),
//底部导航栏
bottomNavigationBar: createBottomNavigationBar(tabs),
),
(scaleAnimation.value != maxRatio || !initFinish)
? ScaleTransition(
scale: scaleAnimation,
child: FadeTransition(
// opacity: 1.0 - (scaleAnimation.value-1 / maxRatio),
opacity: opacityAnimation,
child: Container(
height: initFinish?0:null,
width: double.infinity,
child: Image.asset(
'assets/images/launch_image/launch_image.png',
package: 'zhiying_base_widget',
fit: BoxFit.cover,
),
),
),
)
: Container(width: 0
,height: 0,)
],
);
}

@@ -177,14 +259,13 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
BaseTabModel model = BaseTabModel.fromJson(tabs[index]);
if (await _checkLimit(model)) {
///避免同一个页面多次点击多次重绘
if(_currentIndex==index){
if (_currentIndex == index) {
return;
}else{
} else {
setState(() {
_currentIndex = index;
});
}

}
}),
//底部导航栏
@@ -235,7 +316,6 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
await AppUpdateUtil.updateApp(context);

IntellectCreate.checkAndCreateFirst(context);

}

// 场景还原,记录邀请码
@@ -288,8 +368,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
void showAlert(String text, BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) =>
CupertinoAlertDialog(title: new Text("提示"), content: new Text(text), actions: <Widget>[
builder: (BuildContext context) => CupertinoAlertDialog(title: new Text("提示"), content: new Text(text), actions: <Widget>[
new FlatButton(
child: new Text("OK"),
onPressed: () {


+ 70
- 33
lib/pages/launch_page/launch_page.dart 파일 보기

@@ -20,7 +20,6 @@ import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_comm/util/shared_prefe_util.dart';
import 'package:package_info/package_info.dart';


// 启动页,页面初始化等操作~跟原生启动页保持一致,防止白屏问题
class LaunchPage extends StatefulWidget {
final WidgetBuilder builder;
@@ -31,28 +30,29 @@ class LaunchPage extends StatefulWidget {
_LaunchPageState createState() => _LaunchPageState();
}

class _LaunchPageState extends State<LaunchPage> {
class _LaunchPageState extends State<LaunchPage> with TickerProviderStateMixin {
final GlobalKey navigatorKey = new GlobalKey();

///闪屏动画
AnimationController animationController;

@override
void initState() {
animationController = AnimationController(vsync: this);
Connectivity().checkConnectivity().then((connectivityResult) async {
if (connectivityResult == ConnectivityResult.mobile ||
connectivityResult == ConnectivityResult.wifi) {
if (connectivityResult == ConnectivityResult.mobile || connectivityResult == ConnectivityResult.wifi) {
// I am connected to a wifi network.
Logger.debug('ConnectivityResult.wifi');
print('ConnectivityResult.wifi');
Application.init().then((_) async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String versionNumber =
await SharedPreferencesUtil.getStringValue(Constants.versionNumber);
String currentVersionCode =
packageInfo.buildNumber?.toString() ?? '';
String versionNumber = await SharedPreferencesUtil.getStringValue(Constants.versionNumber);
String currentVersionCode = packageInfo.buildNumber?.toString() ?? '';
if (versionNumber == null || versionNumber == '' || versionNumber != currentVersionCode) {
await _showGuideImage();
SharedPreferencesUtil.setStringValue(Constants.versionNumber, currentVersionCode);
}


if (widget.builder != null) {
Navigator.of(context).pushReplacement(CupertinoPageRoute(builder: widget.builder));
} else {
@@ -61,15 +61,23 @@ class _LaunchPageState extends State<LaunchPage> {
Navigator.of(context).pushReplacementNamed('/homePage');
}
}).catchError((err) async {
if(err.toString().contains("BaseSettingModel")){
await showDialog(context: context,child: TipDialog(content: "基本配置加载失败!请检查网络是否可用后再启动应用!",));
SystemNavigator.pop();
}
if (err.toString().contains("BaseSettingModel")) {
await showDialog(
context: context,
child: TipDialog(
content: "基本配置加载失败!请检查网络是否可用后再启动应用!",
));
SystemNavigator.pop();
}
Logger.error(err);
});
} else {
///在无网络情况下提示用户打开网络
await showDialog(context: context,child: TipDialog(content: "无法连接网络!请打开移动网络/连接WIFI后再尝试",));
await showDialog(
context: context,
child: TipDialog(
content: "无法连接网络!请打开移动网络/连接WIFI后再尝试",
));
Logger.error('未知网络,APP初始化失败');
print('unknow');
SystemNavigator.pop();
@@ -79,33 +87,62 @@ class _LaunchPageState extends State<LaunchPage> {
super.initState();
}

Future _showGuideImage() async {
// 引导页
AppConfigGuideModel guide = AppConfigModel.getConfig()?.guideImage;
if (guide != null && guide.images.length > 0) {
Dio dio = Dio();
// validateInit()async{
// PackageInfo packageInfo = await PackageInfo.fromPlatform();
// String versionNumber =
// await SharedPreferencesUtil.getStringValue(Constants.versionNumber);
// String currentVersionCode =
// packageInfo.buildNumber?.toString() ?? '';
// if (versionNumber == null || versionNumber == '' || versionNumber != currentVersionCode) {
// await _showGuideImage();
// SharedPreferencesUtil.setStringValue(Constants.versionNumber, currentVersionCode);
// }else{
// Navigator.of(context).pushReplacement(
// CupertinoPageRoute(builder: (context) => HomePage()));
// Navigator.of(context).pushReplacementNamed('/homePage');
// }
// }

List<Uint8List> guideImages = List();
for (int i = 0; i < guide.images.length; i++) {
Response response = await dio.get(guide.images[i], options: Options(responseType: ResponseType.bytes));
if (response.statusCode == 200) {
Uint8List data = Uint8List.fromList(response.data);
guideImages.add(data);
Future _showGuideImage() async {
try {
// 引导页
AppConfigGuideModel guide = AppConfigModel
.getConfig()
?.guideImage;
if (guide != null && guide.images.length > 0) {
Dio dio = Dio();
print("加载图片");
List<Uint8List> guideImages = List();
for (int i = 0; i < guide.images.length; i++) {
Response response = await dio.get(guide.images[i], options: Options(responseType: ResponseType.bytes));
if (response.statusCode == 200) {
Uint8List data = Uint8List.fromList(response.data);
guideImages.add(data);
}
}
}

await Navigator.of(context).push(
CupertinoPageRoute(builder: (context) => GuidePage(guide, guideImages)));
await Navigator.of(context).push(CupertinoPageRoute(builder: (context) => GuidePage(guide, guideImages)));
}
}catch(e){
throw "引导图加载失败";
}

}

@override
Widget build(BuildContext context) {
return Image.asset(
'assets/images/launch_image/launch_image.png',
package: 'zhiying_base_widget',
fit: BoxFit.fill,
return Stack(
alignment: Alignment.topCenter,
children: <Widget>[
Container(
color: Colors.white,
width: double.infinity,
child: Image.asset(
'assets/images/launch_image/launch_image.png',
package: 'zhiying_base_widget',
fit: BoxFit.cover,
),
),
],
);
}
}

+ 24
- 7
lib/pages/withdraw_page/withdraw_page.dart 파일 보기

@@ -1,3 +1,4 @@
import 'package:event_bus/event_bus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -7,6 +8,8 @@ import 'package:zhiying_base_widget/pages/withdraw_page/models/withdraw_model.da
import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_page_sk.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/util/event_util/event_util.dart';
import 'package:zhiying_comm/util/event_util/login_success_event.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

/*提现页面*/
@@ -62,9 +65,14 @@ class _WithdrawContainerState extends State<_WithdrawContainer> {
_bloc.loadWithdrawData();
_bloc.getAlipayStatus();
}
EventUtil.instance.on<LoginSuccessEvent>().listen((event) {
reload();
});
super.initState();
}



reload() {
_bloc.loadData(widget.data['skip_identifier']);
_bloc.loadWithdrawData();
@@ -106,7 +114,10 @@ class _WithdrawContainerState extends State<_WithdrawContainer> {

// 导航栏
Widget _createNav(WithdrawModel model) {
return CupertinoNavigationBar(
return AppBar(
elevation: 1,
brightness: Brightness.light,
backgroundColor: HexColor.fromHex(model?.appBarBgColor??""),
leading: Navigator.canPop(context)
? GestureDetector(
child: Container(
@@ -123,23 +134,29 @@ class _WithdrawContainerState extends State<_WithdrawContainer> {
},
)
: Container(),
middle: Text(
centerTitle: true,
title: Text(
model.appBarName,
style: TextStyle(
fontSize: 15,
color: HexColor.fromHex(model.appBarNameColor),
),
),
trailing: GestureDetector(
child: Text(
model.appBarRightText,
style: TextStyle(fontSize: 13, color: Color(0xff333333)),
actions:<Widget>[ GestureDetector(
child: Center(
child: Padding(
padding: EdgeInsets.only(right: 16),
child: Text(
model.appBarRightText,
style: TextStyle(fontSize: 13, color: HexColor.fromHex(model?.appBarNameColor??"")),
),
),
),
onTap: () {
RouterUtil.route(
model.detailSkipModel, model.detailSkipModel.toJson(), context);
},
),
)],
);
}



+ 1
- 1
lib/register.dart 파일 보기

@@ -155,7 +155,7 @@ class BaseWidgetRegister {

// 延迟一秒
Application.addMethod(() async {
return Future.delayed(Duration(seconds: 1));
// return Future.delayed(Duration(seconds: 1));
});
}



+ 2
- 0
pubspec.yaml 파일 보기

@@ -42,6 +42,8 @@ dependencies:
intl: 0.16.1

loading_indicator: ^1.2.0
zhiying_comm:
path: ../zhiying_comm

mobpush_plugin:
dev_dependencies:


불러오는 중...
취소
저장