Skip to content

Commit

Permalink
修复一些 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
imhansai committed Nov 4, 2020
1 parent d18ffe5 commit a005050
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 59 deletions.
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

COCOAPODS: 1.9.3
COCOAPODS: 1.10.0
1 change: 1 addition & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Explore" : MessageLookupByLibrary.simpleMessage("Explore"),
"Guide" : MessageLookupByLibrary.simpleMessage("Guide"),
"Home" : MessageLookupByLibrary.simpleMessage("Home"),
"HomeNews" : MessageLookupByLibrary.simpleMessage("News"),
"LanguageSettings" : MessageLookupByLibrary.simpleMessage("Language Settings"),
"More" : MessageLookupByLibrary.simpleMessage("More"),
"News" : MessageLookupByLibrary.simpleMessage("News"),
Expand Down
1 change: 1 addition & 0 deletions lib/generated/intl/messages_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Explore" : MessageLookupByLibrary.simpleMessage("見る"),
"Guide" : MessageLookupByLibrary.simpleMessage("ガイド"),
"Home" : MessageLookupByLibrary.simpleMessage("ホーム"),
"HomeNews" : MessageLookupByLibrary.simpleMessage("ニュース"),
"LanguageSettings" : MessageLookupByLibrary.simpleMessage("言語設定"),
"More" : MessageLookupByLibrary.simpleMessage("もっと"),
"News" : MessageLookupByLibrary.simpleMessage("ニュース"),
Expand Down
1 change: 1 addition & 0 deletions lib/generated/intl/messages_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Explore" : MessageLookupByLibrary.simpleMessage("探索"),
"Guide" : MessageLookupByLibrary.simpleMessage("导 乘"),
"Home" : MessageLookupByLibrary.simpleMessage("首页"),
"HomeNews" : MessageLookupByLibrary.simpleMessage("资\n讯"),
"LanguageSettings" : MessageLookupByLibrary.simpleMessage("语言设置"),
"More" : MessageLookupByLibrary.simpleMessage("更多"),
"News" : MessageLookupByLibrary.simpleMessage("资 讯"),
Expand Down
10 changes: 10 additions & 0 deletions lib/generated/l10n.dart

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

1 change: 1 addition & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"RouteQuery": "Route Query",
"Guide": "Guide",
"News": "News",
"HomeNews": "News",
"NoNews": "No News",
"NoPictures": "No Pictures",
"SearchLine": "Search Line",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/intl_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"RouteQuery": "ルートクエリ",
"Guide": "ガイド",
"News": "ニュース",
"HomeNews": "ニュース",
"NoNews": "情報はまだありません",
"NoPictures": "写真はしばらくありません",
"SearchLine": "経路を探索する",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"RouteQuery": "线路查询",
"Guide": "导 乘",
"News": "资 讯",
"HomeNews": "资\n讯",
"NoNews": "暂无资讯信息",
"NoPictures": "暂无图片展示",
"SearchLine": "搜索线路",
Expand Down
31 changes: 22 additions & 9 deletions lib/view/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:weifangbus/entity/all_route_data_entity.dart';
import 'package:weifangbus/entity/headline_entity.dart';
Expand Down Expand Up @@ -260,6 +261,8 @@ class _HomePageState extends State<HomePage>

/// 资讯信息
Widget infoShowWidget() {
var currentLocale = Intl.getCurrentLocale();
print('current locale: $currentLocale');
return Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -278,15 +281,25 @@ class _HomePageState extends State<HomePage>
color: Colors.deepOrangeAccent,
),
child: Padding(
child: AutoSizeText(
S.of(context).News,
style: TextStyle(
color: Colors.white,
),
),
padding: EdgeInsets.symmetric(
vertical: 3.h,
horizontal: 12.w,
child: currentLocale == 'zh'
? AutoSizeText(
S.of(context).HomeNews,
style: TextStyle(
color: Colors.white,
),
)
: RotatedBox(
child: AutoSizeText(
S.of(context).HomeNews,
style: TextStyle(
color: Colors.white,
),
maxLines: 1,
),
quarterTurns: 3,
),
padding: EdgeInsets.all(
12.w,
),
),
),
Expand Down
41 changes: 16 additions & 25 deletions lib/view/home/searchbar/search_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,23 @@ class _SearchBarState extends State<SearchBar> {
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).backgroundColor,
borderRadius: BorderRadius.circular(4.0),
borderRadius: BorderRadius.circular(4),
),
child: Row(
children: <Widget>[
Padding(
padding: EdgeInsets.only(
right: 25.w,
left: 25.w,
),
child: Icon(
Icons.search,
size: 60.w,
color: Theme.of(context).accentColor,
),
),
Expanded(
child: MaterialSearchInput(
placeholder: S.of(context).SearchLine,
results: widget.allRouteList,
filter: (dynamic value, String criteria) {
return value.toLowerCase().trim().contains(
RegExp(r'' + criteria.toLowerCase().trim() + ''));
},
),
),
],
child: Padding(
padding: EdgeInsets.only(
left: 25.w,
right: 25.w,
),
child: MaterialSearchInput(
placeholder: S.of(context).SearchLine,
results: widget.allRouteList,
filter: (dynamic value, String criteria) {
return value
.toLowerCase()
.trim()
.contains(RegExp(r'' + criteria.toLowerCase().trim() + ''));
},
),
),
),
);
Expand Down
31 changes: 12 additions & 19 deletions lib/view/home/searchbar/search_input.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:weifangbus/generated/l10n.dart';

typedef bool MaterialSearchFilter<T>(T v, String c);
typedef int MaterialSearchSort<T>(T a, T b, String c);
Expand Down Expand Up @@ -78,8 +79,6 @@ class MaterialSearchInput<T> extends StatefulWidget {
}

class _MaterialSearchInputState<T> extends State<MaterialSearchInput<T>> {
GlobalKey<FormFieldState<T>> _formFieldKey = GlobalKey<FormFieldState<T>>();

/// 调整到线路列表搜索页
_showMaterialSearch(BuildContext context) {
Navigator.push(
Expand All @@ -100,26 +99,19 @@ class _MaterialSearchInputState<T> extends State<MaterialSearchInput<T>> {
);
}

bool _isEmpty(field) {
return field.value == null;
}

Widget build(BuildContext context) {
return InkWell(
onTap: () => _showMaterialSearch(context),
child: FormField<T>(
key: _formFieldKey,
builder: (FormFieldState<T> field) {
return InputDecorator(
isEmpty: _isEmpty(field),
decoration: InputDecoration(
labelText: widget.placeholder,
border: InputBorder.none,
errorText: field.errorText,
),
child: _isEmpty(field) ? null : Text(field.value.toString()),
);
},
child: TextFormField(
decoration: InputDecoration(
hintText: S.of(context).SearchLine,
icon: Icon(
Icons.search,
color: Theme.of(context).accentColor,
),
border: InputBorder.none,
enabled: false,
),
),
);
}
Expand Down Expand Up @@ -233,6 +225,7 @@ class _MaterialSearchState<T> extends State<MaterialSearch> {
return Scaffold(
appBar: AppBar(
title: TextField(
cursorColor: Colors.cyan,
controller: _controller,
autofocus: true,
decoration: InputDecoration.collapsed(hintText: widget.placeholder),
Expand Down
3 changes: 2 additions & 1 deletion lib/view/more/about_software.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:package_info/package_info.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -34,7 +35,7 @@ class _AboutDialog extends StatelessWidget {
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
content: Container(
constraints: const BoxConstraints(maxWidth: 400),
constraints: BoxConstraints(maxWidth: 1.sw),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
Expand Down
12 changes: 8 additions & 4 deletions lib/view/more/more_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:weifangbus/util/font_util.dart';
import 'package:weifangbus/view/more/about_company.dart';
Expand Down Expand Up @@ -135,10 +136,13 @@ class _MorePageState extends State<MorePage>
showDialog(
context: context,
builder: (_) => AlertDialog(
content: AutoSizeText(
"抱歉,检测到您还未安装QQ客户端!",
maxLines: 2,
overflow: TextOverflow.ellipsis,
content: Container(
width: 1.sw,
child: AutoSizeText(
"抱歉,检测到您还未安装QQ客户端!",
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
actions: <Widget>[
FlatButton(
Expand Down

0 comments on commit a005050

Please sign in to comment.