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

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

上级 eb0dc546
......@@ -42,3 +42,4 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
/pubspec.lock
......@@ -32,3 +32,4 @@ Runner/GeneratedPluginRegistrant.*
!default.mode2v3
!default.pbxuser
!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';
import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart';
import 'package:get/route_manager.dart';
import 'package:url_launcher/url_launcher.dart';
// 获取版本号
const String getSystemVersionByNumber =
......@@ -77,3 +78,12 @@ void checkVersion({
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 'package:apk_update/utils/image_utils.dart';
import 'package:apk_update/utils/utils.dart';
import 'package:dio/dio.dart';
import 'package:flustars_flutter3/flustars_flutter3.dart';
import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
class UpdateDialog extends StatefulWidget {
final String? title; // 升级版本
......@@ -50,19 +52,22 @@ class _UpdateDialogState extends State<UpdateDialog> {
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: Center(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.0),
),
child: SizedBox(
width: 280.0,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
// 顶部图片
_topImage(),
Padding(
Container(
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(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
......@@ -75,18 +80,8 @@ class _UpdateDialogState extends State<UpdateDialog> {
value: _value,
)
// 按钮
: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
: Column(
children: <Widget>[
Offstage(
offstage: widget.isUpdateMore,
child: _btn(
title: '残忍拒绝',
textColor: Theme.of(context).primaryColor,
bgColor: Colors.transparent,
onTap: () => Navigator.pop(context),
),
),
_btn(
title: '立即更新',
onTap: () {
......@@ -100,10 +95,20 @@ class _UpdateDialogState extends State<UpdateDialog> {
_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> {
/// 标题、内容
Widget _content({String? title, String? content}) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 15.0),
// 标题
......@@ -145,14 +151,26 @@ class _UpdateDialogState extends State<UpdateDialog> {
),
const SizedBox(height: 5.0),
// 内容
Text(
content ?? "",
style: const TextStyle(fontSize: 15.0, color: Color(0xFF4E5969)),
),
htmlWidget(content),
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({
String? title,
......@@ -163,13 +181,12 @@ class _UpdateDialogState extends State<UpdateDialog> {
InkWell(
onTap: onTap,
child: Container(
width: 110.0,
constraints: const BoxConstraints(minHeight: 36.0),
width: double.infinity,
constraints: const BoxConstraints(minHeight: 40.0),
alignment: Alignment.center,
decoration: BoxDecoration(
color: bgColor ?? Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(20.0),
border: Border.all(color: Theme.of(context).primaryColor),
borderRadius: BorderRadius.circular(4.0),
),
child: Text(
title ?? "",
......@@ -188,6 +205,7 @@ class _UpdateDialogState extends State<UpdateDialog> {
fileName: 'clx_update', category: 'Download', format: 'apk')!;
File file = File(path);
debugPrint("===== Apk下载路径:$path");
/// 链接可能会失效
await Dio().download(
widget.versionPath!,
......
......@@ -19,6 +19,10 @@ dependencies:
fluttertoast: ^8.2.1
# get https://pub.dev/packages/get
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:
flutter_test:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论