Skip to content

Commit

Permalink
Merge pull request #152 from virskor/hotfix/reviews
Browse files Browse the repository at this point in the history
补全const constructors
  • Loading branch information
virskor authored Dec 27, 2020
2 parents c41d363 + e7f0cd8 commit 0ee5a32
Show file tree
Hide file tree
Showing 59 changed files with 223 additions and 220 deletions.
2 changes: 1 addition & 1 deletion mobile/.dart_tool/package_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@
"languageVersion": "2.8"
}
],
"generated": "2020-12-27T04:29:31.547518Z",
"generated": "2020-12-27T07:38:50.371515Z",
"generator": "pub",
"generatorVersion": "2.10.4"
}
2 changes: 1 addition & 1 deletion mobile/.flutter-plugins-dependencies

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mobile/.packages
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by pub on 2020-12-27 12:29:31.492465.
# Generated by pub on 2020-12-27 15:38:50.294086.
archive:file:///Users/virs/.fvm/versions/1.22.5-stable/.pub-cache/hosted/pub.dartlang.org/archive-2.0.13/lib/
args:file:///Users/virs/.fvm/versions/1.22.5-stable/.pub-cache/hosted/pub.dartlang.org/args-1.6.0/lib/
assets_audio_player:../packages/flutter_assetsAudioPlayer/lib/
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/models/attachmentsModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AttachmentsModel {
/// 返回一个空的模型,如果为空的话
///
if (maps == null) {
return AttachmentsModel();
return const AttachmentsModel();
}

dynamic data = maps;
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/models/userFollowModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class UserFollowModel {
: data['id'],
type: data['type'] ?? 'user_follow',
relationships: data['relationships'] == null
? RelationshipsModel()
? const RelationshipsModel()
: RelationshipsModel.fromMap(maps: data['relationships']),
attributes: data['attributes'] == null
? const UserFollowAttributesModel()
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/utils/authHelper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AuthHelper {
expand: true,
backgroundColor: Colors.transparent,
context: context,
builder: (BuildContext context) => CupertinoPageScaffold(
builder: (BuildContext context) => const CupertinoPageScaffold(
resizeToAvoidBottomInset: false,
child: const LoginDelegate(),
));
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/views/accountDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ class _AccountDelegateState extends State<AccountDelegate> {
),
),

Padding(
const Padding(
padding: const EdgeInsets.only(
left: 10, right: 10, top: 20),
child: _LogoutButton())
child: const _LogoutButton())
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/views/forumDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class _ForumDelegateState extends State<ForumDelegate>
return Scaffold(
appBar: PreferredSize(
child: _tabs,
preferredSize: Size.fromHeight(120),
preferredSize: const Size.fromHeight(120),
),
body: Column(
children: <Widget>[
Expand Down
6 changes: 3 additions & 3 deletions mobile/lib/views/gallery/discuzGalleryDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _DiscuzGalleryState extends State<DiscuzGalleryDelegate> {
void initState() {
super.initState();

SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarBrightness: Brightness.dark,
);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
Expand All @@ -61,7 +61,7 @@ class _DiscuzGalleryState extends State<DiscuzGalleryDelegate> {

@override
void dispose() {
SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarBrightness: Brightness.light,
);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
Expand Down Expand Up @@ -96,7 +96,7 @@ class _DiscuzGalleryState extends State<DiscuzGalleryDelegate> {
fontWeight: FontWeight.bold,
fontSize: DiscuzApp.themeOf(context).largeTextSize,
),
DiscuzText(
const DiscuzText(
'/',
color: Colors.white,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _NotificationDelegateState extends State<NotificationListDelegate> {
void initState() {
super.initState();

Future.delayed(Duration(milliseconds: 470))
Future.delayed(const Duration(milliseconds: 470))
.then((_) async => await _requestData(pageNumber: 1));
}

Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/views/notificationsDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _NotificationsDelegateState extends State<NotificationsDelegate> {
///
/// 未读消息
TypeUnreadNotificationsModel _typeUnreadNotifications =
TypeUnreadNotificationsModel();
const TypeUnreadNotificationsModel();

@override
void setState(fn) {
Expand All @@ -52,7 +52,7 @@ class _NotificationsDelegateState extends State<NotificationsDelegate> {
/// 这种不会从接口刷新,仅从状态刷新,如果用户要刷新还是得下拉
/// 或者其他交互逻辑涉及调用 Authhelper.refreshUser 也会自动刷新的
///
Future.delayed(Duration(milliseconds: 500))
Future.delayed(const Duration(milliseconds: 500))
.then((_) => _refreshMessageList(context: context));
}

Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/views/reports/reportsHistoryDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class _ReportHistoryDelegateState extends State<ReportHistoryDelegate> {
title: '我的投诉举报',
brightness: Brightness.light,
),
body: Center(
body: const Center(
child: const DiscuzText('暂无记录'),
),
);
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/views/search/searchSuggestion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class SearchSuggestion extends StatelessWidget {
Widget build(BuildContext context) => SizedBox.expand(
child: Container(
color: DiscuzApp.themeOf(context).scaffoldBackgroundColor,
child: Center(
child: const Center(
child: const DiscuzText('暂无推荐'),
),
));
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/views/search/searchUserDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _SearchUserDelegateState extends State<SearchUserDelegate>
void initState() {
super.initState();

Future.delayed(Duration(milliseconds: 450))
Future.delayed(const Duration(milliseconds: 450))
.then((_) async => await _requestData(pageNumber: 1));
}

Expand All @@ -94,7 +94,7 @@ class _SearchUserDelegateState extends State<SearchUserDelegate>
///
/// 如果keyword 证明用户重新输入了关键字,那么久执行重新请求
if (widget.keyword != null && oldWidget.keyword != widget.keyword) {
Future.delayed(Duration(milliseconds: 450))
Future.delayed(const Duration(milliseconds: 450))
.then((_) async => await _requestData(pageNumber: 1));
}
}
Expand Down
6 changes: 3 additions & 3 deletions mobile/lib/views/threads/threadDetailDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class _ThreadDetailDelegateState extends State<ThreadDetailDelegate> {
void initState() {
super.initState();
this._watchIfPostCommentSuccess();
Future.delayed(Duration(milliseconds: 450)).then((_) async {
Future.delayed(const Duration(milliseconds: 450)).then((_) async {
await _requestThreadDetail(pageNumber: 1);
});
}
Expand Down Expand Up @@ -267,7 +267,7 @@ class _ThreadDetailDelegateState extends State<ThreadDetailDelegate> {
}

if (_threadsCacher.threads.length == 0) {
return SizedBox();
return const SizedBox();
}

/// 遍历图片
Expand Down Expand Up @@ -506,7 +506,7 @@ class _ThreadDetailDelegateState extends State<ThreadDetailDelegate> {
int.tryParse(
widget.thread.relationships.firstPost['data']['id']))
.toList()[0] ??
PostModel();
const PostModel();

/// pageNumber 在onload传入时已经自动加1
/// 注意 主题详情中的meta需要自己生成
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/views/users/blackListDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _BlackListDelegateState extends State<BlackListDelegate> {
@override
void initState() {
super.initState();
Future.delayed(Duration(milliseconds: 450))
Future.delayed(const Duration(milliseconds: 450))
.then((_) async => await _requestData(pageNumber: 1));
}

Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/views/users/follows/followerListDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class _FollowerListDelegateState extends State<FollowerListDelegate> {
///
/// 加载数据
///
Future.delayed(Duration(milliseconds: 450))
Future.delayed(const Duration(milliseconds: 450))
.then((_) async => await _requestData(pageNumber: 1, context: context));
}

Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/views/users/profileDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class _ProfileDelegateState extends State<ProfileDelegate> {
DiscuzListTile(
title: const DiscuzText('头像'),
trailing: AvatarPicker(
avatar: DiscuzAvatar(
avatar: const DiscuzAvatar(
size: 40,
),
),
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/views/users/profiles/userSignatureDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class _UserSignatureDelegateState extends State<UserSignatureDelegate> {
///
/// Initialize user's default signature to auto complete form.
Future<void> _initDefaultValue() async =>
Future.delayed(Duration(milliseconds: 500)).then((_) {
Future.delayed(const Duration(milliseconds: 500)).then((_) {
try {
final UserModel user = context.read<UserProvider>().user;
if (user != null && user.attributes.signature != '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class _UsernameModifyDelegateState extends State<UsernameModifyDelegate> {
///
/// Initialize user's default signature to auto complete form.
Future<void> _initDefaultValue() async =>
Future.delayed(Duration(milliseconds: 500)).then((_) {
Future.delayed(const Duration(milliseconds: 500)).then((_) {
try {
final UserModel user = context.read<UserProvider>().user;
if (user != null && user.attributes.username != '') {
Expand Down
8 changes: 4 additions & 4 deletions mobile/lib/views/users/userHomeDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class _UserHomeDelegateState extends State<UserHomeDelegate> {

///
/// 异步请求新的用户信息
Future.delayed(Duration(milliseconds: 300)).then((_) {
Future.delayed(const Duration(milliseconds: 300)).then((_) {
if (!widget.forceToUpdate) {
return;
}
Expand Down Expand Up @@ -110,11 +110,11 @@ class _UserHomeDelegateState extends State<UserHomeDelegate> {
cardColor: DiscuzApp.themeOf(context).scaffoldBackgroundColor,
),
child: PopupMenuButton<String>(
icon: DiscuzIcon(Icons.more_vert),
icon: const DiscuzIcon(Icons.more_vert),
itemBuilder: (BuildContext context) => <PopupMenuItem<String>>[
PopupMenuItem<String>(
const PopupMenuItem<String>(
value: 'report', child: const DiscuzText('举报')),
PopupMenuItem<String>(
const PopupMenuItem<String>(
value: 'blackList', child: const DiscuzText('拉黑'))
],
onSelected: (String value) {
Expand Down
23 changes: 13 additions & 10 deletions mobile/lib/views/users/walletDelegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _WalletDelegateState extends State<WalletDelegate> {
///
/// wallet data
///
WalletModel _wallet = WalletModel();
WalletModel _wallet = const WalletModel();

final CancelToken _cancelToken = CancelToken();

Expand All @@ -48,7 +48,7 @@ class _WalletDelegateState extends State<WalletDelegate> {
void initState() {
super.initState();

Future.delayed(Duration(milliseconds: 450))
Future.delayed(const Duration(milliseconds: 450))
.then((_) async => await _refreshWallet());
}

Expand All @@ -59,8 +59,9 @@ class _WalletDelegateState extends State<WalletDelegate> {
}

@override
Widget build(BuildContext context) => Consumer<UserProvider>(
builder: (BuildContext context, UserProvider user, Widget child) => Scaffold(
Widget build(BuildContext context) => Consumer<UserProvider>(
builder: (BuildContext context, UserProvider user, Widget child) =>
Scaffold(
appBar: DiscuzAppBar(
brightness: Brightness.dark,
backgroundColor: DiscuzApp.themeOf(context).primaryColor,
Expand Down Expand Up @@ -101,15 +102,15 @@ class _WalletDelegateState extends State<WalletDelegate> {
///
_frozen(),
const DiscuzDivider(),
DiscuzListTile(
const DiscuzListTile(
title: DiscuzText('提现记录'),
),
const DiscuzDivider(),
DiscuzListTile(
const DiscuzListTile(
title: DiscuzText('钱包明细'),
),
const DiscuzDivider(),
DiscuzListTile(
const DiscuzListTile(
title: DiscuzText('订单明细'),
)
],
Expand All @@ -125,7 +126,7 @@ class _WalletDelegateState extends State<WalletDelegate> {
/// 冻结金额
///
Widget _frozen() => DiscuzListTile(
title: DiscuzText('冻结金额'),
title: const DiscuzText('冻结金额'),
trailing: DiscuzText(
_wallet.freezeAmount,
color: DiscuzApp.themeOf(context).greyTextColor,
Expand Down Expand Up @@ -154,8 +155,10 @@ class _WalletDelegateState extends State<WalletDelegate> {
///
///
final UserModel user = context.read<UserProvider>().user;
final String userWalletUrl = "${Urls.usersWallerData}/${user.attributes.id}";
Response resp = await Request(context: context).getUrl(_cancelToken, url: userWalletUrl);
final String userWalletUrl =
"${Urls.usersWallerData}/${user.attributes.id}";
Response resp = await Request(context: context)
.getUrl(_cancelToken, url: userWalletUrl);

if (resp == null) {
setState(() {
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/widgets/appbar/appbarSaveButton.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AppbarSaveButton extends StatelessWidget {
padding:
const EdgeInsets.only(top: 10, bottom: 10, left: 10, right: 10),
child: Container(
constraints: BoxConstraints(minHeight: 40),
constraints: const BoxConstraints(minHeight: 40),
padding:
const EdgeInsets.only(top: 2, bottom: 2, left: 10, right: 10),
alignment: Alignment.centerRight,
Expand Down
6 changes: 3 additions & 3 deletions mobile/lib/widgets/appbar/searchAppbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _SearchAppbarState extends State<SearchAppbar> {
: SystemUiOverlayStyle.dark);

return Container(
padding: EdgeInsets.all(5),
padding: const EdgeInsets.all(5),
decoration:
BoxDecoration(color: DiscuzApp.themeOf(context).backgroundColor),
child: SafeArea(
Expand All @@ -80,7 +80,7 @@ class _SearchAppbarState extends State<SearchAppbar> {
),

AnimatedContainer(
duration: Duration(milliseconds: 270),
duration: const Duration(milliseconds: 270),

///padding: EdgeInsets.only(right: _showButton ? 50 : 0),
padding: EdgeInsets.only(
Expand All @@ -94,7 +94,7 @@ class _SearchAppbarState extends State<SearchAppbar> {
? 50
: 0),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(3)),
borderRadius: const BorderRadius.all(Radius.circular(3)),
color: DiscuzApp.themeOf(context).scaffoldBackgroundColor),
child: DiscuzTextfiled(
controller: _controller,
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/widgets/bottomNavigator/bottomNavigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class _PublishButton extends StatelessWidget {
Widget build(BuildContext context) => Container(
width: _kPublishButtonSize,
height: _kPublishButtonSize,
margin: EdgeInsets.only(top: 4),
margin: const EdgeInsets.only(top: 4),
decoration: BoxDecoration(
color: DiscuzApp.themeOf(context).primaryColor,
borderRadius: const BorderRadius.all(const Radius.circular(60))),
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/widgets/common/avatarPicker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ class _AvatarPickerState extends State<AvatarPicker> {
aspectRatioPresets: [
CropAspectRatioPreset.square,
],
aspectRatio: CropAspectRatio(ratioX: 100, ratioY: 100),
aspectRatio: const CropAspectRatio(ratioX: 100, ratioY: 100),
androidUiSettings: AndroidUiSettings(
toolbarTitle: 'Cropper',
toolbarColor: Theme.of(context).primaryColor,
toolbarWidgetColor: Colors.white,
initAspectRatio: CropAspectRatioPreset.square,
lockAspectRatio: false),
iosUiSettings: IOSUiSettings(
iosUiSettings: const IOSUiSettings(
minimumAspectRatio: 1.0,
resetAspectRatioEnabled: false,
aspectRatioPickerButtonHidden: true,
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/widgets/common/discuzButton.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class DiscuzButton extends StatelessWidget {
width: width,
height: height,
child: ClipRRect(
borderRadius: borderRadius ?? BorderRadius.all(Radius.circular(5)),
borderRadius: borderRadius ?? const BorderRadius.all(const Radius.circular(5)),
child: FlatButton(
padding: padding ??
EdgeInsets.only(top: 5, bottom: 5, right: 10, left: 10),
const EdgeInsets.only(top: 5, bottom: 5, right: 10, left: 10),
color: color ?? DiscuzApp.themeOf(context).primaryColor,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
Expand Down
Loading

0 comments on commit 0ee5a32

Please sign in to comment.