diff --git a/Jsons/version.json b/Jsons/version.json new file mode 100644 index 0000000..f33c4cd --- /dev/null +++ b/Jsons/version.json @@ -0,0 +1,9 @@ +{ + "version": "v1.0.0", + "version_message": "新增xxx功能", + "download_url": { + "android": "https://www.pgyer.com/xxxxxx", + "ios": "https://itunes.apple.com/cn/app/idxxxxxx" + }, + "updated_at": "2023-01-01 00:00:00" +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index b3e851d..4452fbc 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,38 +1,53 @@ - + package="com.app.eoe_fans"> + + + android:name=".MainActivity" + android:exported="true" + android:launchMode="singleTop" + android:theme="@style/LaunchTheme" + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" + android:hardwareAccelerated="true" + android:windowSoftInputMode="adjustResize"> + android:name="io.flutter.embedding.android.NormalTheme" + android:resource="@style/NormalTheme" /> - - + + + android:name="flutterEmbedding" + android:value="2" /> + + + + + + + + diff --git a/assets/efans2.png b/assets/efans2.png new file mode 100644 index 0000000..8f95972 Binary files /dev/null and b/assets/efans2.png differ diff --git a/lib/common/Api.dart b/lib/common/Api.dart index 61a9ef8..551870f 100644 --- a/lib/common/Api.dart +++ b/lib/common/Api.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:dio/dio.dart'; +import 'package:eoe_fans/models/version.dart'; import 'package:eoe_fans/models/videos.dart'; import 'package:eoe_fans/models/iResponse.dart'; import 'package:eoe_fans/models/videosRequest.dart'; @@ -17,7 +18,7 @@ class Api { // Options _options; static Dio dio = - Dio(BaseOptions(baseUrl: 'https://api.eoe.best/eoefans-api/v1', headers: { + Dio(BaseOptions(baseUrl: 'https://api.eoe.best/eoefans-api/v1', headers: { 'ocp-apim-subscription-key': key, 'Content-Type': 'application/json', })); @@ -41,7 +42,7 @@ class Api { ..result = []; if (r.statusCode == 200) { var videoRes = - IResponse.fromJson(r.data, (json) => Videos.fromJson(json)); + IResponse.fromJson(r.data, (json) => Videos.fromJson(json)); print(videoRes.data?.page); print(videoRes.data?.numResults); if (videoRes.data != null) { @@ -50,4 +51,24 @@ class Api { } return tmpVideos; } + + Future version() async { + var paramsData = ({ 'subscription-key': key}); + paramsData.removeWhere((key, value) => value == null); + var r = await dio.get('/tools/version', + queryParameters: paramsData); + var tmpVersion = Version() + ..version = '' + ..version_message = '' + ..download_url = {} + ..updated_at = ''; + if (r.statusCode == 200) { + var versionRes = + IResponse.fromJson(r.data, (json) => Version.fromJson(json)); + if (versionRes.data != null) { + tmpVersion = versionRes.data!; + } + } + return tmpVersion; + } } diff --git a/lib/common/CompareVersion.dart b/lib/common/CompareVersion.dart new file mode 100644 index 0000000..4bedc94 --- /dev/null +++ b/lib/common/CompareVersion.dart @@ -0,0 +1,21 @@ +bool haveNewVersion(String newVersion, String old) { + if (newVersion == null || newVersion.isEmpty || old == null || old.isEmpty) + return false; + int newVersionInt, oldVersion; + var newList = newVersion.split('.'); + var oldList = old.split('.'); + if (newList.length == 0 || oldList.length == 0) { + return false; + } + for (int i = 0; i < newList.length; i++) { + newVersionInt = int.parse(newList[i]); + oldVersion = int.parse(oldList[i]); + if (newVersionInt > oldVersion) { + return true; + } else if (newVersionInt < oldVersion) { + return false; + } + } + + return false; +} diff --git a/lib/main.dart b/lib/main.dart index 9ed653d..925480c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -38,7 +38,7 @@ class MyApp extends StatelessWidget { primarySwatch: Colors.blue, ), routes: { - '/': (BuildContext context) => MainPage(), + '/main': (BuildContext context) => MainPage(), '/splash': (BuildContext context) => SplashScreen(), '/setting': (BuildContext context) => const SettingPage(), '/theme': (BuildContext context) => const SettingTheme(), diff --git a/lib/models/index.dart b/lib/models/index.dart index 95bc529..dcdbf49 100644 --- a/lib/models/index.dart +++ b/lib/models/index.dart @@ -1,3 +1,4 @@ export 'cacheConfig.dart' ; -export 'videos.dart' ; +export 'version.dart' ; export 'video.dart' ; +export 'videos.dart' ; diff --git a/lib/models/version.dart b/lib/models/version.dart new file mode 100644 index 0000000..417f893 --- /dev/null +++ b/lib/models/version.dart @@ -0,0 +1,16 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'version.g.dart'; + +@JsonSerializable() +class Version { + Version(); + + late String version; + late String version_message; + late Map download_url; + late String updated_at; + + factory Version.fromJson(Map json) => _$VersionFromJson(json); + Map toJson() => _$VersionToJson(this); +} diff --git a/lib/models/version.g.dart b/lib/models/version.g.dart new file mode 100644 index 0000000..4a7eae5 --- /dev/null +++ b/lib/models/version.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'version.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +Version _$VersionFromJson(Map json) => Version() + ..version = json['version'] as String + ..version_message = json['version_message'] as String + ..download_url = json['download_url'] as Map + ..updated_at = json['updated_at'] as String; + +Map _$VersionToJson(Version instance) => { + 'version': instance.version, + 'version_message': instance.version_message, + 'download_url': instance.download_url, + 'updated_at': instance.updated_at, + }; diff --git a/lib/routes/mainPage.dart b/lib/routes/mainPage.dart index 8ad42e6..e02e44b 100644 --- a/lib/routes/mainPage.dart +++ b/lib/routes/mainPage.dart @@ -1,7 +1,11 @@ +import 'package:eoe_fans/common/Api.dart'; +import 'package:eoe_fans/common/CompareVersion.dart'; +import 'package:eoe_fans/common/Global.dart'; import 'package:eoe_fans/routes/music/musicPage.dart'; import 'package:eoe_fans/routes/picture/picturePage.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:hgg_app_upgrade/hgg_app_upgrade.dart'; import 'package:provider/provider.dart'; import '../states/ProfileChangeNotifier.dart'; @@ -21,8 +25,25 @@ class _MainPageState extends State { const MusicPage(), ]; + Future _checkAppInfo() async { + var r = await Api().version(); + + if (r.version != '') { + if (haveNewVersion(r.version, Global.packageInfo.version)) { + return AppUpgradeInfo( + title: '新版本 V' + r.version, + contents: r.version_message.split('\n'), + apkDownloadUrl: r.download_url['android'], + force: false, + ); + } + } + return null; + } + @override void initState() { + AppUpgrade.appUpgrade(context, _checkAppInfo()); super.initState(); } diff --git a/lib/routes/setting/aboutUs.dart b/lib/routes/setting/aboutUs.dart index 107c405..c729118 100644 --- a/lib/routes/setting/aboutUs.dart +++ b/lib/routes/setting/aboutUs.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; class AboutUs extends StatefulWidget { const AboutUs({Key? key}) : super(key: key); @@ -24,16 +25,17 @@ class _AboutUsState extends State { Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( - preferredSize: Size.fromHeight(270), + preferredSize: Size.fromHeight(180), child: AppBar( centerTitle: true, flexibleSpace: Container( height: double.maxFinite, + color: HexColor('#ffe3ef'), child: Image( alignment: Alignment.topCenter, image: AssetImage( - 'assets/logo.jpg'), - fit: BoxFit.cover, + 'assets/efans2.png'), + fit: BoxFit.contain, ), ), ), diff --git a/lib/routes/splashPage.dart b/lib/routes/splashPage.dart index b67bd22..2103ff8 100644 --- a/lib/routes/splashPage.dart +++ b/lib/routes/splashPage.dart @@ -21,7 +21,7 @@ class _SplashScreenState extends State { startTime() { _timer = Timer(Duration(milliseconds: 2000), () { _timer.cancel(); - Navigator.of(context).pushReplacementNamed('/'); + Navigator.of(context).pushReplacementNamed('/main'); }); } diff --git a/lib/routes/video/videoPage.dart b/lib/routes/video/videoPage.dart index 41c8a56..4761456 100644 --- a/lib/routes/video/videoPage.dart +++ b/lib/routes/video/videoPage.dart @@ -66,7 +66,7 @@ class _VideoPageState extends State { ), ), body: Container( - padding: const EdgeInsets.only(left: 4, right: 4, top: 4), + padding: const EdgeInsets.only(left: 4, right: 4, top: 8), child: const TabBarView( children: [ VideoList(origin: true), diff --git a/pubspec.lock b/pubspec.lock index 6769400..5018faf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -317,6 +317,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "3.0.1" + hgg_app_upgrade: + dependency: "direct main" + description: + name: hgg_app_upgrade + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" http: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a45450d..063f19e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.1.0+1 +version: 1.2.0+1 environment: sdk: '>=2.18.6 <3.0.0' @@ -48,6 +48,7 @@ dependencies: flutter_swiper_null_safety: ^1.0.2 pull_to_refresh: ^2.0.0 settings_ui: ^2.0.2 + hgg_app_upgrade: ^1.0.0 dev_dependencies: flutter_test: