Skip to content

Commit

Permalink
更新下拉刷新插件:增加国际化
Browse files Browse the repository at this point in the history
App更新逻辑和UI和文字调整
修复ViewStateRefreshListModel泛型问题
  • Loading branch information
phoenixsky committed Sep 23, 2019
1 parent 6a7e363 commit d976ef6
Show file tree
Hide file tree
Showing 14 changed files with 211 additions and 218 deletions.
84 changes: 30 additions & 54 deletions lib/generated/i18n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,40 @@ class S implements WidgetsLocalizations {

String get Like => "Like";
String get about => "About";
String get action_update => "Update";
String get actionCancel => "Cancel";
String get actionConfirm => "Confirm";
String get appName => "Fun Android";
String get appUpdateActionDownloadAgain => "Download";
String get appUpdateActionInstallApk => "Install";
String get appUpdateActionUpdate => "Update";
String get appUpdateCheckUpdate => "Check Update";
String get appUpdateDownloading => "downloading...";
String get appUpdateLeastVersion => "Least version now ";
String get appUpdateReDownloadContent => "It has been detected that it has been downloaded, whether it is installed";
String get appUpdateUpdate => "Version Update";
String get article_tag_top => "Top";
String get autoBySystem => "Auto";
String get cancel => "Cancel";
String get checkUpdate => "Check Update";
String get clear => "Clear";
String get close => "Close";
String get coin => "Coin";
String get collectionRemove => "Remove";
String get confirm => "Confirm";
String get darkMode => "Dark Mode";
String get downloadAgain => "Download";
String get downloadApk => "downloading...";
String get favourites => "Favorites";
String get feedback => "FeedBack";
String get fieldNotNull => "not empty";
String get fontKuaiLe => "ZCOOL KuaiLe";
String get githubIssue => "Can't find mail app,please github issues";
String get installApk => "Install";
String get leastVersion => "Least version now ";
String get loadFailed => "Load failed,retry later";
String get loadMoreFailed => "Load Failed,Click Retry!";
String get loadMoreIdle => "Load More..";
String get loadMoreLoading => "Loading...";
String get loadMoreNoData => "No more data";
String get logout => "Sign Out";
String get myFavourites => "My favourites";
String get needLogin => "Go to Sign In";
String get newVersion => "New Version";
String get noAccount => "No Account ? ";
String get openBrowser => "Open Browser";
String get password => "Password";
String get rate => "Rate";
String get reDownloadApkContent => "It has been detected that it has been downloaded, whether it is installed";
String get rePassword => "Confirm Password";
String get refresh => "Refresh";
String get refreshComplete => "Refresh Complete";
String get refreshIdle => "Pull down to refresh";
String get refreshRefreshWhenRelease => "Refresh when release";
String get refreshTwoLevel => "release to enter second floor";
String get refreshing => "Refreshing...";
String get retry => "Retry";
String get searchHistory => "History";
String get searchHot => "Hot";
Expand All @@ -87,14 +79,14 @@ class S implements WidgetsLocalizations {
String get twoPwdDifferent => "The two passwords differ";
String get unLike => "UnLike";
String get userName => "Username";
String get versionUpdate => "Version Update";
String get viewStateButtonError => "Load Failed";
String get viewStateButtonLogin => "Sign In";
String get viewStateButtonRefresh => "Refresh";
String get viewStateButtonRetry => "Retry";
String get viewStateMessageEmpty => "Nothing Found";
String get viewStateMessageUnAuth => "Not sign in yet";
String get wechatAccount => "Wechat";
String appUpdateFoundNewVersion(String version) => "New version $version";
}

class $en extends S {
Expand All @@ -107,16 +99,10 @@ class $zh_CN extends S {
@override
TextDirection get textDirection => TextDirection.ltr;

@override
String get cancel => "取消";
@override
String get downloadAgain => "重新下载";
@override
String get favourites => "收藏";
@override
String get action_update => "更新";
@override
String get refreshIdle => "下拉可刷新";
String get appUpdateLeastVersion => "已是最新版本";
@override
String get twoPwdDifferent => "两次密码不一致";
@override
Expand All @@ -126,16 +112,14 @@ class $zh_CN extends S {
@override
String get unLike => "取消收藏";
@override
String get reDownloadApkContent => "检测到本地已下载过该版本,是否直接安装";
@override
String get checkUpdate => "检查更新";
@override
String get tabStructure => "体系";
@override
String get signUp => "注册";
@override
String get viewStateMessageEmpty => "空空如也";
@override
String get appUpdateActionInstallApk => "直接安装";
@override
String get viewStateMessageUnAuth => "未登录";
@override
String get setting => "设置";
Expand All @@ -152,44 +136,40 @@ class $zh_CN extends S {
@override
String get Like => "收藏";
@override
String get versionUpdate => "版本更新";
@override
String get loadMoreFailed => "加载失败,请点击重试";
@override
String get refreshRefreshWhenRelease => "释放可刷新";
String get appUpdateActionDownloadAgain => "重新下载";
@override
String get autoBySystem => "跟随系统";
@override
String get refreshComplete => "刷新完成";
@override
String get viewStateButtonRefresh => "刷新一下";
@override
String get loadFailed => "加载失败,请稍后重试";
@override
String get installApk => "直接安装";
@override
String get refreshTwoLevel => "欢迎光临,我的空中楼阁";
@override
String get article_tag_top => "置顶";
@override
String get appUpdateReDownloadContent => "检测到本地已下载过该版本,是否直接安装";
@override
String get noAccount => "还没账号? ";
@override
String get viewStateButtonError => "加载失败";
@override
String get downloadApk => "下载中,请稍后...";
@override
String get loadMoreIdle => "上拉加载更多";
@override
String get openBrowser => "浏览器打开";
@override
String get appUpdateActionUpdate => "更新";
@override
String get coin => "积分";
@override
String get splashSkip => "跳过";
@override
String get collectionRemove => "移除收藏";
@override
String get actionConfirm => "确认";
@override
String get fontKuaiLe => "快乐字体";
@override
String get appUpdateCheckUpdate => "检查更新";
@override
String get settingLanguage => "多语言";
@override
String get myFavourites => "我的收藏";
Expand All @@ -198,24 +178,26 @@ class $zh_CN extends S {
@override
String get rate => "评分";
@override
String get actionCancel => "取消";
@override
String get theme => "色彩主题";
@override
String get share => "分享";
@override
String get fieldNotNull => "不能为空";
String get appUpdateUpdate => "版本更新";
@override
String get leastVersion => "已是最新版本";
String get fieldNotNull => "不能为空";
@override
String get close => "关闭";
@override
String get retry => "重试";
@override
String get wechatAccount => "公众号";
@override
String get loadMoreLoading => "加载中...";
@override
String get toSignUp => "去注册";
@override
String get appUpdateDownloading => "下载中,请稍后...";
@override
String get appName => "玩Android";
@override
String get tabUser => "我的";
Expand All @@ -230,14 +212,10 @@ class $zh_CN extends S {
@override
String get userName => "用户名";
@override
String get confirm => "确认";
@override
String get tabHome => "首页";
@override
String get tabProject => "项目";
@override
String get refreshing => "刷新中";
@override
String get rePassword => "确认密码";
@override
String get signIn => "登录";
Expand All @@ -252,9 +230,7 @@ class $zh_CN extends S {
@override
String get searchHistory => "历史搜索";
@override
String get loadMoreNoData => "没有更多数据了";
@override
String get newVersion => "发现新版本,是否更新";
String appUpdateFoundNewVersion(String version) => "发现新版本$version,是否更新";
}

class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class App extends StatelessWidget {
locale: localeModel.locale,
localizationsDelegates: const [
S.delegate,
RefreshLocalizations.delegate,//下拉刷新
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/view_state_refresh_list_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'view_state_list_model.dart';

/// 基于
abstract class ViewStateRefreshListModel<T> extends ViewStateListModel {
abstract class ViewStateRefreshListModel<T> extends ViewStateListModel<T> {
/// 分页第一页页码
static const int pageNumFirst = 0;

Expand Down
2 changes: 1 addition & 1 deletion lib/service/app_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class AppRepository {
queryParameters: {'where': '{"platform":"$platform"}'});
var result = response.data[0];
debugPrint('当前版本为===>$version');
debugPrint('最新版本为===>${result['version']}');
if (result['version'] != version) {
debugPrint('发现新版本===>${result['version']}\nurl:${result['url']}');
return result['url'];
}
return null;
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/helper/dialog_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class DialogHelper {
Navigator.of(context).pop(false);
},
child: Text(
S.of(context).cancel,
S.of(context).actionCancel,
),
),
CupertinoDialogAction(
onPressed: () async {
Navigator.of(context).pop(true);
},
child: Text(S.of(context).confirm),
child: Text(S.of(context).actionConfirm),
),
],
));
Expand Down
12 changes: 4 additions & 8 deletions lib/ui/helper/refresh_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ class HomeRefreshHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClassicHeader(
idleText: S.of(context).refreshIdle,
releaseText: S.of(context).refreshRefreshWhenRelease,
refreshingText: S.of(context).refreshing,
completeText: S.of(context).refreshComplete,
canTwoLevelText: S.of(context).refreshTwoLevel,
textStyle: TextStyle(color: Colors.white),
outerBuilder: (child) => HomeSecondFloorOuter(child),
Expand All @@ -27,10 +23,10 @@ class RefresherFooter extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClassicFooter(
failedText: S.of(context).loadMoreFailed,
idleText: S.of(context).loadMoreIdle,
loadingText: S.of(context).loadMoreLoading,
noDataText: S.of(context).loadMoreNoData,
// failedText: S.of(context).loadMoreFailed,
// idleText: S.of(context).loadMoreIdle,
// loadingText: S.of(context).loadMoreLoading,
// noDataText: S.of(context).loadMoreNoData,
);
}
}
2 changes: 1 addition & 1 deletion lib/ui/page/change_log_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ChangeLogPage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(S.of(context).versionUpdate),
title: Text(S.of(context).appUpdateCheckUpdate),
),
body: SafeArea(
child: Stack(children: <Widget>[
Expand Down
11 changes: 1 addition & 10 deletions lib/ui/page/tab/tab_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fun_android/generated/i18n.dart';
import 'package:fun_android/ui/widget/app_update.dart';
import 'package:fun_android/view_model/app_model.dart';

import 'home_page.dart';
import 'project_page.dart';
Expand Down Expand Up @@ -89,15 +88,7 @@ class _TabNavigatorState extends State<TabNavigator> {

@override
void initState() {
checkAppUpdate();
checkAppUpdate(context);
super.initState();
}

Future checkAppUpdate() async {
String url = await AppUpdateModel().checkUpdate();
if (url?.isNotEmpty ?? false) {
bool result = await showUpdateDialog(context);
if (result == true) downloadApp(context, url);
}
}
}
5 changes: 4 additions & 1 deletion lib/ui/page/tab/user_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class UserListWidget extends StatelessWidget {
trailing: Icon(Icons.chevron_right),
),
ListTile(
title: Text(S.of(context).versionUpdate),
title: Text(S.of(context).appUpdateCheckUpdate),
onTap: () {
Navigator.push(
context,
Expand All @@ -228,6 +228,9 @@ class UserListWidget extends StatelessWidget {
),
trailing: Icon(Icons.chevron_right),
),
SizedBox(
height: 30,
)
]),
),
);
Expand Down
Loading

0 comments on commit d976ef6

Please sign in to comment.