Skip to content

Commit

Permalink
日常优化
Browse files Browse the repository at this point in the history
  • Loading branch information
simplezhli committed Mar 30, 2021
1 parent 3d0fddf commit ae336ca
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 39 deletions.
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@

<meta-data
android:name="flutterEmbedding"
android:value="2" />
android:value="2" />

<!-- 高德地图 -->
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="29017a09c0b0279853577be7df682513"/>
Expand Down
12 changes: 4 additions & 8 deletions android/app/src/main/java/com/weilu/deer/InstallAPKPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry.Registrar;

/**
* @author weilu
*/
public class InstallAPKPlugin implements FlutterPlugin {

private MethodChannel channel;
private Activity mActivity;
private final Activity mActivity;

public InstallAPKPlugin(Activity activity) {
this.mActivity = activity;
}

/** Plugin registration. */
public static void registerWith(Registrar registrar) {
InstallAPKPlugin plugin = new InstallAPKPlugin(registrar.activity());
plugin.setupMethodChannel(registrar.messenger());
}

@Override
public void onAttachedToEngine(@NonNull FlutterPlugin.FlutterPluginBinding binding) {
setupMethodChannel(binding.getBinaryMessenger());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<color android:color="#FF18191A"/>
<color android:color="@color/dark_bg_color"/>
</item>

<!-- You can insert your own image assets here -->
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="dark_bg_color">#FF18191A</color>
</resources>
12 changes: 11 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
buildscript {
ext.kotlin_version = '1.3.72'
ext.kotlin_version = '1.4.30'
repositories {
// maven { url 'https://maven.aliyun.com/repository/public' }//jcenter
// maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }//gradle-plugin
// maven { url 'https://maven.aliyun.com/repository/central' }//central
// maven { url 'https://maven.aliyun.com/repository/google' }//google
google()
jcenter()
maven { url 'https://jitpack.io' }
}

dependencies {
Expand All @@ -13,8 +18,13 @@ buildscript {

allprojects {
repositories {
// maven { url 'https://maven.aliyun.com/repository/public' }
// maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
// maven { url 'https://maven.aliyun.com/repository/central' }
// maven { url 'https://maven.aliyun.com/repository/google' }
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

Expand Down
19 changes: 17 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true

# 提升编译速度配置 https://blog.csdn.net/weixin_33943347/article/details/91361727
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx3072m -XX:+UseParallelGC -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# 开启gradle缓存
org.gradle.caching=true
android.enableBuildCache=true

#开启 kotlin 的增量和并行编译
kotlin.incremental=true
kotlin.incremental.java=true
kotlin.incremental.js=true
kotlin.caching.enabled=true
kotlin.parallel.tasks.in.project=true
25 changes: 25 additions & 0 deletions lib/goods/page/qr_code_scanner_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_deer/routers/fluro_navigator.dart';
import 'package:flutter_deer/widgets/my_app_bar.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';

class QrCodeScannerPage extends StatefulWidget {
Expand Down Expand Up @@ -53,6 +54,30 @@ class _QrCodeScannerPageState extends State<QrCodeScannerPage> {
),
),
),
Positioned(
bottom: 60,
left: 0,
right: 0,
child: Center(
child: IconButton(
icon: const Icon(Icons.highlight_outlined, size: 32, color: Colors.white,),
onPressed: () {
if (controller != null) {
controller.toggleFlash();
}
},
),
),
),
const Positioned(
top: 0,
left: 0,
right: 0,
child: MyAppBar(
backgroundColor: Colors.transparent,
backImgColor: Colors.white,
),
),
],
),
);
Expand Down
22 changes: 12 additions & 10 deletions lib/login/widgets/my_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ class _MyTextFieldState extends State<MyTextField> {
@override
void initState() {
/// 获取初始化值
_isShowDelete = widget.controller.text.isEmpty;
_isShowDelete = widget.controller.text.isNotEmpty;
/// 监听输入改变
widget.controller.addListener(isEmpty);
super.initState();
}

void isEmpty() {
final bool isEmpty = widget.controller.text.isEmpty;
final bool isNotEmpty = widget.controller.text.isNotEmpty;
/// 状态不一样在刷新,避免重复不必要的setState
if (isEmpty != _isShowDelete) {
if (isNotEmpty != _isShowDelete) {
setState(() {
_isShowDelete = isEmpty;
_isShowDelete = isNotEmpty;
});
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ class _MyTextFieldState extends State<MyTextField> {

Widget clearButton;

if (!_isShowDelete) {
if (_isShowDelete) {
clearButton = Semantics(
label: '清空',
hint: '清空输入框',
Expand Down Expand Up @@ -195,11 +195,13 @@ class _MyTextFieldState extends State<MyTextField> {
Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
if (_isShowDelete) Gaps.empty else clearButton,
if (!widget.isInputPwd) Gaps.empty else Gaps.hGap15,
if (!widget.isInputPwd) Gaps.empty else pwdVisible,
if (widget.getVCode == null) Gaps.empty else Gaps.hGap15,
if (widget.getVCode == null) Gaps.empty else getVCodeButton,
/// _isShowDelete参数动态变化,为了不破坏树结构,false时放一个空Widget。
/// 对于其他参数,为初始配置参数,基本可以确定树结构,就不做空Widget处理。
if (_isShowDelete) clearButton else Gaps.empty,
if (widget.isInputPwd) Gaps.hGap15,
if (widget.isInputPwd) pwdVisible,
if (widget.getVCode != null) Gaps.hGap15,
if (widget.getVCode != null) getVCodeButton,
],
)
],
Expand Down
16 changes: 1 addition & 15 deletions lib/setting/page/theme_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ class ThemePage extends StatefulWidget {
class _ThemePageState extends State<ThemePage> {

final List<String> _list = <String>['跟随系统', '开启', '关闭'];
// StreamSubscription _subscription;

// @override
// void dispose() {
// _subscription?.cancel();
// super.dispose();
// }

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -54,14 +47,7 @@ class _ThemePageState extends State<ThemePage> {
// Provider.of<ThemeProvider>(context, listen: false).setTheme(themeMode);
/// 与上方等价,provider 4.1.0添加的拓展方法
context.read<ThemeProvider>().setTheme(themeMode);
// _subscription?.cancel();
// /// 主题切换动画200毫秒
// _subscription = Stream.value(1).delay(Duration(milliseconds: 200)).listen((_) {
// if (!mounted) {
// return;
// }
// ThemeUtils.setSystemNavigationBarStyle(context, themeMode);
// });
setState(() {});
},
child: Container(
alignment: Alignment.centerLeft,
Expand Down
4 changes: 3 additions & 1 deletion lib/widgets/my_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
this.centerTitle = '',
this.actionName = '',
this.backImg = 'assets/images/ic_back_black.png',
this.backImgColor,
this.onPressed,
this.isBack = true
}): super(key: key);
Expand All @@ -23,6 +24,7 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
final String title;
final String centerTitle;
final String backImg;
final Color backImgColor;
final String actionName;
final VoidCallback onPressed;
final bool isBack;
Expand All @@ -49,7 +51,7 @@ class MyAppBar extends StatelessWidget implements PreferredSizeWidget {
padding: const EdgeInsets.all(12.0),
icon: Image.asset(
backImg,
color: ThemeUtils.getIconColor(context),
color: backImgColor ?? ThemeUtils.getIconColor(context),
),
) : Gaps.empty;

Expand Down

0 comments on commit ae336ca

Please sign in to comment.