Skip to content
This repository has been archived by the owner on May 20, 2022. It is now read-only.

Commit

Permalink
upgrade to flutter 3
Browse files Browse the repository at this point in the history
  • Loading branch information
xkeyC committed May 20, 2022
1 parent 6c54a9f commit 2a88300
Show file tree
Hide file tree
Showing 19 changed files with 314 additions and 280 deletions.
12 changes: 8 additions & 4 deletions lib/data/decoder/flarum/src/discussions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ class FlarumDiscussionsData extends FlarumBaseData {

final List<FlarumDiscussionData> discussionsList;

FlarumDiscussionsData(FlarumLinkData? links, data, FlarumIncludedData? included,
String sourceJsonString, this.discussionsList)
FlarumDiscussionsData(
FlarumLinkData? links,
data,
FlarumIncludedData? included,
String sourceJsonString,
this.discussionsList)
: super(links, data, included, sourceJsonString);

factory FlarumDiscussionsData.formBase(FlarumBaseData flarumBaseData) {
Expand Down Expand Up @@ -38,8 +42,8 @@ class FlarumDiscussionsData extends FlarumBaseData {
class FlarumDiscussionData extends FlarumBaseData {
static const String typeName = "discussions";

FlarumDiscussionData(FlarumLinkData? links, data, FlarumIncludedData? included,
String sourceJsonString)
FlarumDiscussionData(FlarumLinkData? links, data,
FlarumIncludedData? included, String sourceJsonString)
: super(links, data, included, sourceJsonString);

factory FlarumDiscussionData.formBase(FlarumBaseData flarumBaseData) {
Expand Down
9 changes: 4 additions & 5 deletions lib/generated/intl/messages_all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ MessageLookupByLibrary? _findExact(String localeName) {
/// User programs should call this before using [localeName] for messages.
Future<bool> initializeMessages(String localeName) async {
var availableLocale = Intl.verifiedLocale(
localeName,
(locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
localeName, (locale) => _deferredLibraries[locale] != null,
onFailure: (_) => null);
if (availableLocale == null) {
return new Future.value(false);
}
Expand All @@ -60,8 +59,8 @@ bool _messagesExistFor(String locale) {
}

MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
onFailure: (_) => null);
var actualLocale =
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
if (actualLocale == null) return null;
return _findExact(actualLocale);
}
47 changes: 29 additions & 18 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
Expand All @@ -19,21 +20,31 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en';

final Map<String, dynamic> messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function> {
"c_site_follow" : MessageLookupByLibrary.simpleMessage("This site will show on your Home Page"),
"c_site_speed_level" : MessageLookupByLibrary.simpleMessage("A good connection speed will improve your experience."),
"c_site_speed_warning" : MessageLookupByLibrary.simpleMessage("The speed of this site is not good, which may affect your experience, do you continue to follow?"),
"c_site_url_label" : MessageLookupByLibrary.simpleMessage("Flarum site URL,Must use HTTPS"),
"c_site_url_label_error" : MessageLookupByLibrary.simpleMessage("ERROR! Please check network or URL"),
"title_SPEED_LEVEL" : MessageLookupByLibrary.simpleMessage("SPEED LEVEL: "),
"title_add_site" : MessageLookupByLibrary.simpleMessage("Add Flarum Site:"),
"title_add_site_first" : MessageLookupByLibrary.simpleMessage("Welcome! \\nAdd Your First Flarum Site:"),
"title_no" : MessageLookupByLibrary.simpleMessage("NO"),
"title_retest_speed" : MessageLookupByLibrary.simpleMessage("RETEST SPEED"),
"title_site_conf" : MessageLookupByLibrary.simpleMessage("Site Conf"),
"title_site_follow" : MessageLookupByLibrary.simpleMessage("Follow This Site"),
"title_warning" : MessageLookupByLibrary.simpleMessage("WARNING"),
"title_yes" : MessageLookupByLibrary.simpleMessage("YES")
};
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"c_site_follow": MessageLookupByLibrary.simpleMessage(
"This site will show on your Home Page"),
"c_site_speed_level": MessageLookupByLibrary.simpleMessage(
"A good connection speed will improve your experience."),
"c_site_speed_warning": MessageLookupByLibrary.simpleMessage(
"The speed of this site is not good, which may affect your experience, do you continue to follow?"),
"c_site_url_label": MessageLookupByLibrary.simpleMessage(
"Flarum site URL,Must use HTTPS"),
"c_site_url_label_error": MessageLookupByLibrary.simpleMessage(
"ERROR! Please check network or URL"),
"title_SPEED_LEVEL":
MessageLookupByLibrary.simpleMessage("SPEED LEVEL: "),
"title_add_site":
MessageLookupByLibrary.simpleMessage("Add Flarum Site:"),
"title_add_site_first": MessageLookupByLibrary.simpleMessage(
"Welcome! \\nAdd Your First Flarum Site:"),
"title_no": MessageLookupByLibrary.simpleMessage("NO"),
"title_retest_speed":
MessageLookupByLibrary.simpleMessage("RETEST SPEED"),
"title_site_conf": MessageLookupByLibrary.simpleMessage("Site Conf"),
"title_site_follow":
MessageLookupByLibrary.simpleMessage("Follow This Site"),
"title_warning": MessageLookupByLibrary.simpleMessage("WARNING"),
"title_yes": MessageLookupByLibrary.simpleMessage("YES")
};
}
42 changes: 24 additions & 18 deletions lib/generated/intl/messages_zh_CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new
// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering
// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases
// ignore_for_file:unused_import, file_names
// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes
// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes

import 'package:intl/intl.dart';
import 'package:intl/message_lookup_by_library.dart';
Expand All @@ -19,21 +20,26 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'zh_CN';

final Map<String, dynamic> messages = _notInlinedMessages(_notInlinedMessages);
static _notInlinedMessages(_) => <String, Function> {
"c_site_follow" : MessageLookupByLibrary.simpleMessage("这个网站将会出现在您的首页"),
"c_site_speed_level" : MessageLookupByLibrary.simpleMessage("优秀的连接速度可以提高您的浏览体验。"),
"c_site_speed_warning" : MessageLookupByLibrary.simpleMessage("此站点速度不佳,可能会影响您的使用体验,是否继续关注?"),
"c_site_url_label" : MessageLookupByLibrary.simpleMessage("Flarum 站点链接,必须使用 HTTPS"),
"c_site_url_label_error" : MessageLookupByLibrary.simpleMessage("出错了!请检网络是否正常,链接是否正确。"),
"title_SPEED_LEVEL" : MessageLookupByLibrary.simpleMessage("速度等级: "),
"title_add_site" : MessageLookupByLibrary.simpleMessage("添加 Flarum 站点:"),
"title_add_site_first" : MessageLookupByLibrary.simpleMessage("欢迎! \n添加您的第一个 Flarum 站点:"),
"title_no" : MessageLookupByLibrary.simpleMessage("不"),
"title_retest_speed" : MessageLookupByLibrary.simpleMessage("重新测速"),
"title_site_conf" : MessageLookupByLibrary.simpleMessage("站点配置"),
"title_site_follow" : MessageLookupByLibrary.simpleMessage("关注此站点"),
"title_warning" : MessageLookupByLibrary.simpleMessage("警告"),
"title_yes" : MessageLookupByLibrary.simpleMessage("是的")
};
final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"c_site_follow": MessageLookupByLibrary.simpleMessage("这个网站将会出现在您的首页"),
"c_site_speed_level":
MessageLookupByLibrary.simpleMessage("优秀的连接速度可以提高您的浏览体验。"),
"c_site_speed_warning":
MessageLookupByLibrary.simpleMessage("此站点速度不佳,可能会影响您的使用体验,是否继续关注?"),
"c_site_url_label":
MessageLookupByLibrary.simpleMessage("Flarum 站点链接,必须使用 HTTPS"),
"c_site_url_label_error":
MessageLookupByLibrary.simpleMessage("出错了!请检网络是否正常,链接是否正确。"),
"title_SPEED_LEVEL": MessageLookupByLibrary.simpleMessage("速度等级: "),
"title_add_site": MessageLookupByLibrary.simpleMessage("添加 Flarum 站点:"),
"title_add_site_first":
MessageLookupByLibrary.simpleMessage("欢迎! \n添加您的第一个 Flarum 站点:"),
"title_no": MessageLookupByLibrary.simpleMessage("不"),
"title_retest_speed": MessageLookupByLibrary.simpleMessage("重新测速"),
"title_site_conf": MessageLookupByLibrary.simpleMessage("站点配置"),
"title_site_follow": MessageLookupByLibrary.simpleMessage("关注此站点"),
"title_warning": MessageLookupByLibrary.simpleMessage("警告"),
"title_yes": MessageLookupByLibrary.simpleMessage("是的")
};
}
45 changes: 30 additions & 15 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 16 additions & 15 deletions lib/ui/AddSiteUI.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> {
context: context,
builder: (context) {
return AlertDialog(
title: Text(S.of(context)!.title_warning),
content: Text(S.of(context)!.c_site_speed_warning),
title: Text(S.of(context).title_warning),
content: Text(S.of(context).c_site_speed_warning),
actions: [
TextButton(
onPressed: () {
Expand All @@ -139,18 +139,18 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> {
follow = true;
});
},
child: Text(S.of(context)!.title_yes)),
child: Text(S.of(context).title_yes)),
TextButton(
onPressed: () {
Navigator.pop(context);
_checkSpeed();
},
child: Text(S.of(context)!.title_retest_speed)),
child: Text(S.of(context).title_retest_speed)),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text(S.of(context)!.title_no))
child: Text(S.of(context).title_no))
],
);
});
Expand Down Expand Up @@ -258,7 +258,7 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> {
children: [
ListTile(
title: Text(
S.of(context)!.title_site_conf,
S.of(context).title_site_conf,
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 20),
),
Expand All @@ -268,7 +268,7 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> {
ListTile(
title: RichText(
text: TextSpan(
text: S.of(context)!.title_SPEED_LEVEL,
text: S.of(context).title_SPEED_LEVEL,
style: TextStyle(
color: getTextColor(context),
fontSize: 18,
Expand All @@ -279,7 +279,8 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> {
itemBuilder: (BuildContext context,
int index) {
Color c = Colors.amber;
if (info!.siteConnectionSpeedLevel! <=
if (info!
.siteConnectionSpeedLevel! <=
1) {
c = Colors.green;
} else if (info!
Expand All @@ -303,7 +304,7 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> {
)
]),
),
subtitle: Text(S.of(context)!.c_site_speed_level),
subtitle: Text(S.of(context).c_site_speed_level),
trailing: IconButton(
onPressed: isSpeedChecking ? null : _checkSpeed,
icon: isSpeedChecking
Expand All @@ -315,9 +316,9 @@ class _CheckSiteInfoPageState extends State<_CheckSiteInfoPage> {
/// Site Follow
ListTile(
title: Text(
S.of(context)!.title_site_follow,
S.of(context).title_site_follow,
),
subtitle: Text(S.of(context)!.c_site_follow),
subtitle: Text(S.of(context).c_site_follow),
leading: Checkbox(
onChanged: _followSite,
value: follow,
Expand Down Expand Up @@ -427,8 +428,8 @@ class _AddSiteMainPageState extends State<_AddSiteMainPage> {
children: [
Text(
widget.firstSite
? S.of(context)!.title_add_site_first
: S.of(context)!.title_add_site,
? S.of(context).title_add_site_first
: S.of(context).title_add_site,
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
Expand All @@ -444,9 +445,9 @@ class _AddSiteMainPageState extends State<_AddSiteMainPage> {
enabled: loadStatus != 1,
controller: urlTextController,
decoration: InputDecoration(
labelText: S.of(context)!.c_site_url_label,
labelText: S.of(context).c_site_url_label,
errorText: loadStatus == -2
? S.of(context)!.c_site_url_label_error
? S.of(context).c_site_url_label_error
: null),
onChanged: (String text) {
if (StringUtil.isHTTPSUrl(text)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/MainUI.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _MainUIState extends State<MainUI> {
child: fabIsLoading
? CircularProgressIndicator()
: FaIcon(
FontAwesomeIcons.pencilAlt,
FontAwesomeIcons.pencil,
color: getTextColor(context),
),
onPressed: () {},
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/MainUI_desktop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class _MainUIDesktopState extends State<MainUIDesktop> {
heroTag: "main_fab",
isExtended: isExtended,
icon: FaIcon(
FontAwesomeIcons.pencilAlt,
FontAwesomeIcons.pencil,
color: getTextColor(context),
),
label: makeTitleText(context, "Start a Discussion"),
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/SplashUI.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import '../conf.dart';
import '../generated/l10n.dart';

class SplashUI extends StatefulWidget {
@override
Expand Down Expand Up @@ -84,6 +85,7 @@ class _SplashUIState extends State<SplashUI> with TickerProviderStateMixin {
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
S.delegate,
],
supportedLocales: [
Locale('en', ''),
Expand Down
Loading

0 comments on commit 2a88300

Please sign in to comment.