Skip to content

Commit 823a9cc

Browse files
Fix bugs
1 parent bb15e55 commit 823a9cc

15 files changed

+291
-195
lines changed

lib/Models/github_response.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:convert';
2+
13
///Release,A release.
24
class ReleaseItem {
35
List<ReleaseAsset> assets;
@@ -177,7 +179,13 @@ class ReleaseAsset {
177179
"updated_at": updatedAt.toIso8601String(),
178180
"uploader": uploader,
179181
"url": url,
182+
'pkgs_download_url': pkgsDownloadUrl,
180183
};
184+
185+
@override
186+
String toString() {
187+
return jsonEncode(toJson());
188+
}
181189
}
182190

183191
///State of the release asset.

lib/Screens/Info/history_screen.dart

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'package:loftify/Api/user_api.dart';
77
import 'package:loftify/Models/history_response.dart';
88
import 'package:loftify/Resources/theme.dart';
99
import 'package:loftify/Utils/hive_util.dart';
10+
import 'package:loftify/Widgets/Dialog/dialog_builder.dart';
1011

1112
import '../../Models/post_detail_response.dart';
1213
import '../../Utils/constant.dart';
@@ -88,7 +89,6 @@ class _HistoryScreenState extends State<HistoryScreen>
8889
_histories.add(PostDetailData.fromJson(e));
8990
}
9091
}
91-
if (mounted) setState(() {});
9292
_initPhase = InitPhase.successful;
9393
if (_histories.length >= _total && !refresh) {
9494
_noMore = true;
@@ -148,12 +148,13 @@ class _HistoryScreenState extends State<HistoryScreen>
148148
onLoad: _onLoad,
149149
triggerAxis: Axis.vertical,
150150
childBuilder: (context, physics) {
151-
return _archiveDataList.isNotEmpty
151+
return _archiveDataList.isNotEmpty && _histories.isNotEmpty
152152
? _buildNineGridGroup(physics)
153153
: ItemBuilder.buildEmptyPlaceholder(
154154
context: context,
155155
text: S.current.noHistory,
156156
physics: physics,
157+
shrinkWrap: false,
157158
);
158159
},
159160
),
@@ -264,17 +265,25 @@ class _HistoryScreenState extends State<HistoryScreen>
264265
ContextMenuButtonConfig(
265266
S.current.clearMyHistory,
266267
onPressed: () {
267-
UserApi.clearHistory().then((value) {
268-
if (value['meta']['status'] != 200) {
269-
IToast.showTop(value['meta']['desc'] ?? value['meta']['msg']);
270-
} else {
271-
_histories.clear();
272-
_archiveDataList.clear();
273-
_total = 0;
274-
setState(() {});
275-
IToast.showTop(S.current.clearSuccess);
276-
}
277-
});
268+
DialogBuilder.showConfirmDialog(
269+
context,
270+
title: S.current.clearMyHistory,
271+
message: S.current.clearMyHistoryMessage,
272+
onTapConfirm: () {
273+
UserApi.clearHistory().then((value) {
274+
if (value['meta']['status'] != 200) {
275+
IToast.showTop(
276+
value['meta']['desc'] ?? value['meta']['msg']);
277+
} else {
278+
_histories.clear();
279+
_archiveDataList.clear();
280+
_total = 0;
281+
setState(() {});
282+
IToast.showTop(S.current.clearSuccess);
283+
}
284+
});
285+
},
286+
);
278287
},
279288
),
280289
ContextMenuButtonConfig(
@@ -298,23 +307,39 @@ class _HistoryScreenState extends State<HistoryScreen>
298307
: S.current.openMyHistory,
299308
onPressed: () {
300309
HiveUtil.getUserInfo().then((blogInfo) async {
301-
UserApi.closeHistory(
302-
recordHistory: _recordHistory == 1 ? 0 : 1,
303-
blogName: blogInfo!.blogName,
304-
).then((value) {
305-
if (value['meta']['status'] != 200) {
306-
IToast.showTop(value['meta']['desc'] ?? value['meta']['msg']);
307-
} else {
308-
_histories.clear();
309-
_archiveDataList.clear();
310-
_total = 0;
311-
_recordHistory = _recordHistory == 1 ? 0 : 1;
312-
IToast.showTop(_recordHistory == 1
313-
? S.current.openSuccess
314-
: S.current.closeSuccess);
315-
setState(() {});
316-
}
317-
});
310+
close() {
311+
UserApi.closeHistory(
312+
recordHistory: _recordHistory == 1 ? 0 : 1,
313+
blogName: blogInfo!.blogName,
314+
).then((value) {
315+
if (value['meta']['status'] != 200) {
316+
IToast.showTop(
317+
value['meta']['desc'] ?? value['meta']['msg']);
318+
} else {
319+
_histories.clear();
320+
_archiveDataList.clear();
321+
_total = 0;
322+
_recordHistory = _recordHistory == 1 ? 0 : 1;
323+
IToast.showTop(_recordHistory == 1
324+
? S.current.openSuccess
325+
: S.current.closeSuccess);
326+
setState(() {});
327+
}
328+
});
329+
}
330+
331+
if (_recordHistory == 1) {
332+
DialogBuilder.showConfirmDialog(
333+
context,
334+
title: S.current.closeMyHistory,
335+
message: S.current.closeMyHistoryMessage,
336+
onTapConfirm: () {
337+
close();
338+
},
339+
);
340+
} else {
341+
close();
342+
}
318343
});
319344
},
320345
),

lib/Screens/Info/like_screen.dart

Lines changed: 69 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import 'dart:io';
22

3+
import 'package:context_menus/context_menus.dart';
34
import 'package:flutter/material.dart';
45
import 'package:flutter/services.dart';
56
import 'package:loftify/Api/user_api.dart';
67
import 'package:loftify/Models/history_response.dart';
78
import 'package:loftify/Resources/theme.dart';
89
import 'package:loftify/Utils/hive_util.dart';
9-
import 'package:tuple/tuple.dart';
1010

1111
import '../../Models/post_detail_response.dart';
12+
import '../../Utils/constant.dart';
1213
import '../../Utils/enums.dart';
1314
import '../../Utils/ilogger.dart';
1415
import '../../Utils/itoast.dart';
16+
import '../../Utils/responsive_util.dart';
1517
import '../../Utils/utils.dart';
1618
import '../../Widgets/BottomSheet/bottom_sheet_builder.dart';
17-
import '../../Widgets/BottomSheet/list_bottom_sheet.dart';
1819
import '../../Widgets/General/EasyRefresh/easy_refresh.dart';
1920
import '../../Widgets/Item/item_builder.dart';
2021
import '../../Widgets/PostItem/common_info_post_item_builder.dart';
@@ -183,18 +184,31 @@ class _LikeScreenState extends State<LikeScreen>
183184
onTap: _onRefresh,
184185
);
185186
case InitPhase.successful:
186-
return EasyRefresh.builder(
187-
refreshOnStart: true,
188-
controller: _refreshController,
189-
onRefresh: _onRefresh,
190-
onLoad: _onLoad,
191-
triggerAxis: Axis.vertical,
192-
childBuilder: (context, physics) {
193-
return _archiveDataList.isNotEmpty
194-
? _buildNineGridGroup(physics)
195-
: ItemBuilder.buildEmptyPlaceholder(
196-
context: context, text: S.current.noLike, physics: physics);
197-
},
187+
return Stack(
188+
children: [
189+
EasyRefresh.builder(
190+
refreshOnStart: true,
191+
controller: _refreshController,
192+
onRefresh: _onRefresh,
193+
onLoad: _onLoad,
194+
triggerAxis: Axis.vertical,
195+
childBuilder: (context, physics) {
196+
return _archiveDataList.isNotEmpty && _likeList.isNotEmpty
197+
? _buildNineGridGroup(physics)
198+
: ItemBuilder.buildEmptyPlaceholder(
199+
context: context,
200+
text: S.current.noLike,
201+
physics: physics,
202+
shrinkWrap: false,
203+
);
204+
},
205+
),
206+
Positioned(
207+
right: ResponsiveUtil.isLandscape() ? 16 : 12,
208+
bottom: ResponsiveUtil.isLandscape() ? 16 : 76,
209+
child: _buildFloatingButtons(),
210+
),
211+
],
198212
);
199213
default:
200214
return Container();
@@ -261,40 +275,50 @@ class _LikeScreenState extends State<LikeScreen>
261275
icon: Icon(Icons.more_vert_rounded,
262276
color: Theme.of(context).iconTheme.color),
263277
onTap: () {
264-
BottomSheetBuilder.showListBottomSheet(
265-
context,
266-
(sheetContext) => TileList.fromOptions(
267-
[
268-
Tuple2(S.current.clearInvalidContent, 1),
269-
],
270-
(idx) async {
271-
Navigator.pop(sheetContext);
272-
if (idx == 1) {
273-
UserApi.deleteInvalidLike(
274-
blogId: await HiveUtil.getUserId())
275-
.then((value) {
276-
if (value['meta']['status'] != 200) {
277-
IToast.showTop(
278-
value['meta']['desc'] ?? value['meta']['msg']);
279-
} else {
280-
_likeList.removeWhere(
281-
(e) => CommonInfoItemBuilder.isInvalid(e));
282-
setState(() {});
283-
IToast.showTop(S.current.clearSuccess);
284-
}
285-
});
286-
}
287-
},
288-
showCancel: true,
289-
context: sheetContext,
290-
showTitle: false,
291-
onCloseTap: () => Navigator.pop(sheetContext),
292-
crossAxisAlignment: CrossAxisAlignment.center,
293-
),
294-
);
278+
BottomSheetBuilder.showContextMenu(context, _buildMoreButtons());
295279
}),
296280
const SizedBox(width: 5),
297281
],
298282
);
299283
}
284+
285+
_buildMoreButtons() {
286+
return GenericContextMenu(
287+
buttonConfigs: [
288+
ContextMenuButtonConfig(
289+
S.current.clearInvalidContent,
290+
onPressed: () async {
291+
UserApi.deleteInvalidLike(blogId: await HiveUtil.getUserId())
292+
.then((value) {
293+
if (value['meta']['status'] != 200) {
294+
IToast.showTop(value['meta']['desc'] ?? value['meta']['msg']);
295+
} else {
296+
_likeList
297+
.removeWhere((e) => CommonInfoItemBuilder.isInvalid(e));
298+
setState(() {});
299+
IToast.showTop(S.current.clearSuccess);
300+
}
301+
});
302+
},
303+
),
304+
],
305+
);
306+
}
307+
308+
_buildFloatingButtons() {
309+
return ResponsiveUtil.isLandscape()
310+
? Column(
311+
children: [
312+
ItemBuilder.buildShadowIconButton(
313+
context: context,
314+
icon: const Icon(Icons.more_vert_rounded),
315+
onTap: () {
316+
BottomSheetBuilder.showContextMenu(
317+
context, _buildMoreButtons());
318+
},
319+
),
320+
],
321+
)
322+
: emptyWidget;
323+
}
300324
}

lib/Screens/Lock/pin_change_screen.dart

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
import 'dart:math';
22

33
import 'package:flutter/material.dart';
4-
import 'package:flutter/services.dart';
5-
import 'package:local_auth/error_codes.dart' as auth_error;
6-
import 'package:local_auth/local_auth.dart';
7-
import 'package:local_auth_android/local_auth_android.dart';
4+
import 'package:loftify/Utils/app_provider.dart';
85
import 'package:loftify/Utils/itoast.dart';
96
import 'package:loftify/Utils/responsive_util.dart';
107
import 'package:loftify/Widgets/General/Unlock/gesture_notifier.dart';
118
import 'package:loftify/Widgets/General/Unlock/gesture_unlock_indicator.dart';
129
import 'package:loftify/Widgets/General/Unlock/gesture_unlock_view.dart';
1310
import 'package:loftify/Widgets/Item/item_builder.dart';
14-
import 'package:package_info_plus/package_info_plus.dart';
1511

16-
import '../../Utils/constant.dart';
1712
import '../../Utils/hive_util.dart';
18-
import '../../Utils/ilogger.dart';
1913
import '../../Utils/utils.dart';
2014
import '../../generated/l10n.dart';
2115

@@ -53,7 +47,6 @@ class PinChangeScreenState extends State<PinChangeScreen> {
5347
}
5448
}
5549

56-
5750
void auth() async {
5851
await Utils.localAuth(onAuthed: () {
5952
IToast.showTop(S.current.biometricVerifySuccess);
@@ -110,13 +103,8 @@ class PinChangeScreenState extends State<PinChangeScreen> {
110103
onCompleted: _gestureComplete,
111104
),
112105
),
113-
GestureDetector(
114-
onTap: () {
115-
if (_isEditMode && _isUseBiometric) {
116-
auth();
117-
}
118-
},
119-
child: ItemBuilder.buildRoundButton(
106+
if (_isEditMode && _isUseBiometric)
107+
ItemBuilder.buildRoundButton(
120108
context,
121109
text: ResponsiveUtil.isWindows()
122110
? S.current.biometricVerifyPin
@@ -125,7 +113,6 @@ class PinChangeScreenState extends State<PinChangeScreen> {
125113
auth();
126114
},
127115
),
128-
),
129116
const SizedBox(height: 50),
130117
],
131118
),
@@ -172,6 +159,7 @@ class PinChangeScreenState extends State<PinChangeScreen> {
172159
});
173160
HiveUtil.put(HiveUtil.guesturePasswdKey,
174161
GestureUnlockView.selectedToString(selected));
162+
appProvider.pinSettled = HiveUtil.hasGuesturePasswd();
175163
} else {
176164
setState(() {
177165
_notifier.setStatus(

0 commit comments

Comments
 (0)