版本更新(部分),社区楼主发帖

pull/1/head
戴余标 3 years ago
parent 8803402213
commit a5d69f5a6e

@ -36,6 +36,7 @@ import 'package:aku_new_community/ui/profile/car/car_manage_page.dart';
import 'package:aku_new_community/ui/profile/car_parking/car_parking_page.dart'; import 'package:aku_new_community/ui/profile/car_parking/car_parking_page.dart';
import 'package:aku_new_community/ui/profile/house/house_owners_page.dart'; import 'package:aku_new_community/ui/profile/house/house_owners_page.dart';
/// ///
///Application Object ///Application Object
class AO { class AO {

@ -12,6 +12,7 @@ import 'package:flutter_sound_web/flutter_sound_web.dart';
import 'package:image_picker_for_web/image_picker_for_web.dart'; import 'package:image_picker_for_web/image_picker_for_web.dart';
import 'package:just_audio_web/just_audio_web.dart'; import 'package:just_audio_web/just_audio_web.dart';
import 'package:package_info_plus_web/package_info_plus_web.dart'; import 'package:package_info_plus_web/package_info_plus_web.dart';
import 'package:shared_preferences_web/shared_preferences_web.dart';
import 'package:url_launcher_web/url_launcher_web.dart'; import 'package:url_launcher_web/url_launcher_web.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart';
@ -24,6 +25,7 @@ void registerPlugins(Registrar registrar) {
ImagePickerPlugin.registerWith(registrar); ImagePickerPlugin.registerWith(registrar);
JustAudioPlugin.registerWith(registrar); JustAudioPlugin.registerWith(registrar);
PackageInfoPlugin.registerWith(registrar); PackageInfoPlugin.registerWith(registrar);
SharedPreferencesPlugin.registerWith(registrar);
UrlLauncherPlugin.registerWith(registrar); UrlLauncherPlugin.registerWith(registrar);
registrar.registerMessageHandler(); registrar.registerMessageHandler();
} }

@ -1,4 +1,5 @@
import 'package:aku_new_community/provider/old_age_provider.dart'; import 'package:aku_new_community/provider/old_age_provider.dart';
import 'package:aku_new_community/utils/updater_page.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';

@ -419,7 +419,7 @@ class _HomePageState extends State<HomePage>
)), )),
SliverToBoxAdapter( SliverToBoxAdapter(
child: 48.hb, child: 48.hb,
) ),
], ],
), ),
), ),

@ -14,6 +14,7 @@ import 'package:aku_new_community/ui/market/market_page.dart';
import 'package:aku_new_community/utils/websocket/web_socket_util.dart'; import 'package:aku_new_community/utils/websocket/web_socket_util.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart'; import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/others/user_tool.dart'; import 'package:aku_new_community/widget/others/user_tool.dart';
import '../utils/updater_page.dart';
import 'home/home_page.dart'; import 'home/home_page.dart';
import 'opening_code_page/opening_code_page.dart'; import 'opening_code_page/opening_code_page.dart';
import 'personal/personal_page.dart'; import 'personal/personal_page.dart';
@ -181,7 +182,8 @@ class _TabNavigatorState extends State<TabNavigator>
4, 4,
), ),
]; ];
return BeeScaffold( return UpdaterPage(
BeeScaffold(
body: WillPopScope( body: WillPopScope(
onWillPop: () async { onWillPop: () async {
if (_lastPressed == null || if (_lastPressed == null ||
@ -216,6 +218,9 @@ class _TabNavigatorState extends State<TabNavigator>
), ),
), ),
), ),
); )
)
;
} }
} }

@ -28,11 +28,13 @@ import 'package:aku_new_community/widget/bee_scaffold.dart';
class EventDetailPage extends StatefulWidget { class EventDetailPage extends StatefulWidget {
final int dynamicId; final int dynamicId;
final int? createId;
final VoidCallback? refresh; final VoidCallback? refresh;
EventDetailPage({ EventDetailPage({
Key? key, Key? key,
required this.dynamicId, required this.dynamicId,
this.createId,
this.refresh, this.refresh,
}) : super(key: key); }) : super(key: key);
@ -533,7 +535,7 @@ class _EventDetailPageState extends State<EventDetailPage> {
fontSize: 28.sp, fontSize: 28.sp,
), ),
children: [ children: [
if (createId == model.createId) if (model.createId ==widget.createId)
WidgetSpan( WidgetSpan(
child: Container( child: Container(
width: 56.w, width: 56.w,

@ -144,7 +144,7 @@ class _ChatCardState extends State<ChatCard> {
), ),
20.wb, 20.wb,
GestureDetector( GestureDetector(
onTap: () => Get.to(EventDetailPage(dynamicId: widget.model.id)), onTap: () => Get.to(EventDetailPage(dynamicId: widget.model.id,createId: widget.model.createId,)),
child: Material( child: Material(
color: Colors.transparent, color: Colors.transparent,
child: Row( child: Row(
@ -194,6 +194,7 @@ class _ChatCardState extends State<ChatCard> {
? () async { ? () async {
await Get.to(() => EventDetailPage( await Get.to(() => EventDetailPage(
dynamicId: widget.model.id, dynamicId: widget.model.id,
createId: widget.model.createId,
refresh: widget.refresh, refresh: widget.refresh,
)); ));
widget.refresh(); widget.refresh();

@ -0,0 +1,3 @@
class Constants {
static final String timeStart = "timeStart";
}

@ -0,0 +1,10 @@
import 'package:sp_util/sp_util.dart';
import 'constants.dart';
class DataUtil {
static saveCurrentTimeMillis(int timeStart) async {
await SpUtil.getInstance();
SpUtil.putInt(Constants.timeStart, timeStart);
}
}

@ -0,0 +1,174 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';
import 'package:dio/dio.dart';
import 'package:sp_util/sp_util.dart';
import 'package:url_launcher/url_launcher.dart';
import 'constants.dart';
import 'data_util.dart';
class UpdaterPage extends StatefulWidget {
final Widget child;
const UpdaterPage(this.child);
@override
UpdatePagerState createState() => UpdatePagerState();
}
class UpdatePagerState extends State<UpdaterPage> {
var _serviceVersionCode,
_serviceVersionName,
_serviceVersionPlatform,
_serviceVersionApp;
@override
void initState() {
super.initState();
//APP
var timeEnd = DateTime.now().millisecondsSinceEpoch;
_getNewVersionAPP();
//"Later"
var timeStart = SpUtil.getInt(Constants.timeStart);
if (timeStart == 0) {
//APP"版本更新"
_getNewVersionAPP();
} else if (timeStart != 0 && timeEnd - timeStart! >= 24 * 60 * 60 * 1000) {
//
_getNewVersionAPP();
}
}
//
_getNewVersionAPP() async {
String url = "/appversions/latest"; //URLURL
try {
Response response = await Dio().get(url);
setState(() {
var data = response.data;
_serviceVersionCode = data["versionCode"].toString(); //
_serviceVersionName = data["versionName"].toString(); //
_serviceVersionPlatform = data["versionPlatform"].toString(); //
_serviceVersionApp = data["versionApp"].toString(); //URL
_checkVersionCode();
});
} catch (e) {
print(e);
}
_checkVersionCode();
}
//
_checkVersionCode() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String _currentVersionCode = packageInfo.version;
print('版本——————————————————————'+ '${_currentVersionCode}');
int serviceVersionCode = int.parse(_serviceVersionCode);
print(serviceVersionCode);
int currentVersionCode = int.parse(_currentVersionCode);
print(currentVersionCode);
if (serviceVersionCode > currentVersionCode) {
_showNewVersionAppDialog(); //
}
}
//"版本更新"
Future<void> _showNewVersionAppDialog() async {
print('弹出框');
if (_serviceVersionPlatform == "android") {
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Row(
children: <Widget>[
Image.asset("images/ic_launcher_icon.png",
height: 35.0, width: 35.0),
Padding(
padding: EdgeInsets.fromLTRB(30.0, 0.0, 10.0, 0.0),
child: Text('项目名称',
style: TextStyle(
color: Color(0xFF384F6F), fontSize: 20.0),),)
],
),
content: Text('提示的内容',
style: TextStyle(
color: Color(0xFF384F6F), fontSize: 18.0),),
actions: [
OutlinedButton(
child: new Text('稍后再说',
style: TextStyle(
color: Color(0xFF384F6F), fontSize: 20.0),),
onPressed: () {
Navigator.of(context).pop();
var timeStart = DateTime.now().millisecondsSinceEpoch;
DataUtil.saveCurrentTimeMillis(timeStart); //
},
),
OutlinedButton(
child: new Text('下载',
style: TextStyle(
color: Color(0xFF384F6F), fontSize: 20.0)),
onPressed: () {
//https://play.google.com/store/apps/details?id=
launch(_serviceVersionApp); //Google Play
Navigator.of(context).pop();
},
)
],
);
});
} else {
//iOS
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return CupertinoAlertDialog(
title:Row(
children: <Widget>[
Image.asset("images/ic_launcher_icon.png",
height: 35.0, width: 35.0),
Padding(
padding: EdgeInsets.fromLTRB(30.0, 0.0, 10.0, 0.0),
child: Text('项目名称',
style: TextStyle(
color: Color(0xFF384F6F), fontSize: 20.0),),)
],
),
content: Text('提示的内容',
style: TextStyle(
color: Color(0xFF384F6F), fontSize: 18.0),),
actions: [
OutlinedButton(
child: new Text('稍后再说',
style: TextStyle(
color: Color(0xFF384F6F), fontSize: 20.0),),
onPressed: () {
Navigator.of(context).pop();
var timeStart = DateTime.now().millisecondsSinceEpoch;
DataUtil.saveCurrentTimeMillis(timeStart); //
},
),
OutlinedButton(
child: new Text('下载',
style: TextStyle(
color: Color(0xFF384F6F), fontSize: 20.0)),
onPressed: () {
//https://play.google.com/store/apps/details?id=
launch(_serviceVersionApp); //Google Play
Navigator.of(context).pop();
},
),
],
);
});
}
}
@override
Widget build(BuildContext context) => widget.child;
}

@ -11,6 +11,7 @@ import just_audio
import package_info import package_info
import package_info_plus_macos import package_info_plus_macos
import path_provider_macos import path_provider_macos
import shared_preferences_macos
import sqflite import sqflite
import url_launcher_macos import url_launcher_macos
@ -21,6 +22,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin")) FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
} }

@ -1128,6 +1128,62 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.4" version: "2.0.4"
shared_preferences:
dependency: transitive
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.15"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
shelf: shelf:
dependency: transitive dependency: transitive
description: description:
@ -1189,6 +1245,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.2" version: "1.8.2"
sp_util:
dependency: "direct main"
description:
name: sp_util
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
sqflite: sqflite:
dependency: transitive dependency: transitive
description: description:

@ -127,6 +127,7 @@ dependencies:
like_button: ^2.0.4 like_button: ^2.0.4
#图片扩展 #图片扩展
extended_image: ^6.1.0 extended_image: ^6.1.0
sp_util: ^2.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save