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

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/house/house_owners_page.dart';
///
///Application Object
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:just_audio_web/just_audio_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:flutter_web_plugins/flutter_web_plugins.dart';
@ -24,6 +25,7 @@ void registerPlugins(Registrar registrar) {
ImagePickerPlugin.registerWith(registrar);
JustAudioPlugin.registerWith(registrar);
PackageInfoPlugin.registerWith(registrar);
SharedPreferencesPlugin.registerWith(registrar);
UrlLauncherPlugin.registerWith(registrar);
registrar.registerMessageHandler();
}

@ -1,4 +1,5 @@
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/material.dart';

@ -419,7 +419,7 @@ class _HomePageState extends State<HomePage>
)),
SliverToBoxAdapter(
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/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import '../utils/updater_page.dart';
import 'home/home_page.dart';
import 'opening_code_page/opening_code_page.dart';
import 'personal/personal_page.dart';
@ -181,41 +182,45 @@ class _TabNavigatorState extends State<TabNavigator>
4,
),
];
return BeeScaffold(
body: WillPopScope(
onWillPop: () async {
if (_lastPressed == null ||
DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) {
//1
_lastPressed = DateTime.now();
BotToast.showText(text: '再点击一次返回退出');
return false;
}
//app
WebSocketUtil().closeWebSocket();
return true;
},
child: TabBarView(
children: _pages,
controller: _tabController,
physics: NeverScrollableScrollPhysics(),
),
),
bottomNavi: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 750.w, maxHeight: 146.w),
child: Container(
margin:
return UpdaterPage(
BeeScaffold(
body: WillPopScope(
onWillPop: () async {
if (_lastPressed == null ||
DateTime.now().difference(_lastPressed!) > Duration(seconds: 1)) {
//1
_lastPressed = DateTime.now();
BotToast.showText(text: '再点击一次返回退出');
return false;
}
//app
WebSocketUtil().closeWebSocket();
return true;
},
child: TabBarView(
children: _pages,
controller: _tabController,
physics: NeverScrollableScrollPhysics(),
),
),
bottomNavi: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 750.w, maxHeight: 146.w),
child: Container(
margin:
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
decoration: BoxDecoration(
image: DecorationImage(
image: Assets.home.imgTabdi, fit: BoxFit.fitWidth),
color: Colors.transparent),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: _bottomNav.cast<Widget>().toList(),
decoration: BoxDecoration(
image: DecorationImage(
image: Assets.home.imgTabdi, fit: BoxFit.fitWidth),
color: Colors.transparent),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: _bottomNav.cast<Widget>().toList(),
),
),
),
),
),
);
)
)
;
}
}

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

@ -144,7 +144,7 @@ class _ChatCardState extends State<ChatCard> {
),
20.wb,
GestureDetector(
onTap: () => Get.to(EventDetailPage(dynamicId: widget.model.id)),
onTap: () => Get.to(EventDetailPage(dynamicId: widget.model.id,createId: widget.model.createId,)),
child: Material(
color: Colors.transparent,
child: Row(
@ -194,6 +194,7 @@ class _ChatCardState extends State<ChatCard> {
? () async {
await Get.to(() => EventDetailPage(
dynamicId: widget.model.id,
createId: widget.model.createId,
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_plus_macos
import path_provider_macos
import shared_preferences_macos
import sqflite
import url_launcher_macos
@ -21,6 +22,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTPackageInfoPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}

@ -1128,6 +1128,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:
@ -1189,6 +1245,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:

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

Loading…
Cancel
Save