提交 542183f9 authored 作者: shixiaochen's avatar shixiaochen

1、适配顶部透明图片样式、底部按钮样式;2、升级内容支持a链接跳转(Android跳转应用市场、iOS跳转AppStore);

上级 eb0dc546
...@@ -42,3 +42,4 @@ app.*.map.json ...@@ -42,3 +42,4 @@ app.*.map.json
/android/app/debug /android/app/debug
/android/app/profile /android/app/profile
/android/app/release /android/app/release
/pubspec.lock
...@@ -32,3 +32,4 @@ Runner/GeneratedPluginRegistrant.* ...@@ -32,3 +32,4 @@ Runner/GeneratedPluginRegistrant.*
!default.mode2v3 !default.mode2v3
!default.pbxuser !default.pbxuser
!default.perspectivev3 !default.perspectivev3
/Podfile.lock
PODS:
- apk_update (0.0.1):
- Flutter
- Flutter (1.0.0)
- fluttertoast (0.0.2):
- Flutter
- Toast
- integration_test (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- Toast (4.0.0)
DEPENDENCIES:
- apk_update (from `.symlinks/plugins/apk_update/ios`)
- Flutter (from `Flutter`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
SPEC REPOS:
trunk:
- Toast
EXTERNAL SOURCES:
apk_update:
:path: ".symlinks/plugins/apk_update/ios"
Flutter:
:path: Flutter
fluttertoast:
:path: ".symlinks/plugins/fluttertoast/ios"
integration_test:
:path: ".symlinks/plugins/integration_test/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
SPEC CHECKSUMS:
apk_update: 3ea73f5eaf6c9816a7f7e3ceaca627b7e87d0889
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
fluttertoast: fafc4fa4d01a6a9e4f772ecd190ffa525e9e2d9c
integration_test: 13825b8a9334a850581300559b8839134b124670
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
PODFILE CHECKSUM: 02caaa843f6501172c0d470d80e72f61175c8b93
COCOAPODS: 1.12.1
差异被折叠。
...@@ -4,6 +4,7 @@ import 'package:dio/dio.dart'; ...@@ -4,6 +4,7 @@ import 'package:dio/dio.dart';
import 'package:flustars_flutter3/flustars_flutter3.dart'; import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/route_manager.dart'; import 'package:get/route_manager.dart';
import 'package:url_launcher/url_launcher.dart';
// 获取版本号 // 获取版本号
const String getSystemVersionByNumber = const String getSystemVersionByNumber =
...@@ -77,3 +78,12 @@ void checkVersion({ ...@@ -77,3 +78,12 @@ void checkVersion({
debugPrint("===== 网络请求错误:${e.response?.statusCode} ${e.response?.statusMessage}"); debugPrint("===== 网络请求错误:${e.response?.statusCode} ${e.response?.statusMessage}");
} }
} }
/// 打开浏览器
Future<void> openBrowser(String stringUrl) async {
final Uri url = Uri.parse(stringUrl);
if (!await launchUrl(url, mode: LaunchMode.externalApplication)) {
throw Exception('Could not launch $url');
}
}
import 'dart:io'; import 'dart:io';
import 'package:apk_update/utils/image_utils.dart'; import 'package:apk_update/utils/image_utils.dart';
import 'package:apk_update/utils/utils.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flustars_flutter3/flustars_flutter3.dart'; import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
class UpdateDialog extends StatefulWidget { class UpdateDialog extends StatefulWidget {
final String? title; // 升级版本 final String? title; // 升级版本
...@@ -50,19 +52,22 @@ class _UpdateDialogState extends State<UpdateDialog> { ...@@ -50,19 +52,22 @@ class _UpdateDialogState extends State<UpdateDialog> {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
body: Center( body: Center(
child: Container( child: SizedBox(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.0),
),
width: 280.0, width: 280.0,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
// 顶部图片 // 顶部图片
_topImage(), _topImage(),
Padding( Container(
padding: const EdgeInsets.symmetric(horizontal: 15.0), padding: const EdgeInsets.symmetric(horizontal: 15.0),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(8.0),
bottomRight: Radius.circular(8.0),
),
),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
...@@ -75,18 +80,8 @@ class _UpdateDialogState extends State<UpdateDialog> { ...@@ -75,18 +80,8 @@ class _UpdateDialogState extends State<UpdateDialog> {
value: _value, value: _value,
) )
// 按钮 // 按钮
: Row( : Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
Offstage(
offstage: widget.isUpdateMore,
child: _btn(
title: '残忍拒绝',
textColor: Theme.of(context).primaryColor,
bgColor: Colors.transparent,
onTap: () => Navigator.pop(context),
),
),
_btn( _btn(
title: '立即更新', title: '立即更新',
onTap: () { onTap: () {
...@@ -100,10 +95,20 @@ class _UpdateDialogState extends State<UpdateDialog> { ...@@ -100,10 +95,20 @@ class _UpdateDialogState extends State<UpdateDialog> {
_download(); _download();
} }
}, },
) ),
const SizedBox(height: 5.0),
Offstage(
offstage: widget.isUpdateMore,
child: _btn(
title: '忽略此版本',
textColor: const Color(0xFF666666),
bgColor: Colors.transparent,
onTap: () => Navigator.pop(context),
),
),
], ],
), ),
const SizedBox(height: 15.0), const SizedBox(height: 10.0),
], ],
), ),
), ),
...@@ -133,6 +138,7 @@ class _UpdateDialogState extends State<UpdateDialog> { ...@@ -133,6 +138,7 @@ class _UpdateDialogState extends State<UpdateDialog> {
/// 标题、内容 /// 标题、内容
Widget _content({String? title, String? content}) => Column( Widget _content({String? title, String? content}) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const SizedBox(height: 15.0), const SizedBox(height: 15.0),
// 标题 // 标题
...@@ -145,14 +151,26 @@ class _UpdateDialogState extends State<UpdateDialog> { ...@@ -145,14 +151,26 @@ class _UpdateDialogState extends State<UpdateDialog> {
), ),
const SizedBox(height: 5.0), const SizedBox(height: 5.0),
// 内容 // 内容
Text( htmlWidget(content),
content ?? "",
style: const TextStyle(fontSize: 15.0, color: Color(0xFF4E5969)),
),
const SizedBox(height: 15.0), const SizedBox(height: 15.0),
], ],
); );
/// 显示html内容
Widget htmlWidget(String? content) {
return HtmlWidget(
widget.content ?? "",
onTapUrl: (url) {
if (Platform.isIOS) {
widget.jumpAppStore?.call();
} else {
openBrowser(url);
}
return true;
},
);
}
/// 按钮 /// 按钮
Widget _btn({ Widget _btn({
String? title, String? title,
...@@ -163,13 +181,12 @@ class _UpdateDialogState extends State<UpdateDialog> { ...@@ -163,13 +181,12 @@ class _UpdateDialogState extends State<UpdateDialog> {
InkWell( InkWell(
onTap: onTap, onTap: onTap,
child: Container( child: Container(
width: 110.0, width: double.infinity,
constraints: const BoxConstraints(minHeight: 36.0), constraints: const BoxConstraints(minHeight: 40.0),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: bgColor ?? Theme.of(context).primaryColor, color: bgColor ?? Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(20.0), borderRadius: BorderRadius.circular(4.0),
border: Border.all(color: Theme.of(context).primaryColor),
), ),
child: Text( child: Text(
title ?? "", title ?? "",
...@@ -188,6 +205,7 @@ class _UpdateDialogState extends State<UpdateDialog> { ...@@ -188,6 +205,7 @@ class _UpdateDialogState extends State<UpdateDialog> {
fileName: 'clx_update', category: 'Download', format: 'apk')!; fileName: 'clx_update', category: 'Download', format: 'apk')!;
File file = File(path); File file = File(path);
debugPrint("===== Apk下载路径:$path"); debugPrint("===== Apk下载路径:$path");
/// 链接可能会失效 /// 链接可能会失效
await Dio().download( await Dio().download(
widget.versionPath!, widget.versionPath!,
......
...@@ -19,6 +19,10 @@ dependencies: ...@@ -19,6 +19,10 @@ dependencies:
fluttertoast: ^8.2.1 fluttertoast: ^8.2.1
# get https://pub.dev/packages/get # get https://pub.dev/packages/get
get: ^4.6.5 get: ^4.6.5
# https://pub.dev/packages/flutter_widget_from_html_core
flutter_widget_from_html_core: ^0.10.0
# https://pub.dev/packages/url_launcher
url_launcher: ^6.1.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论