Skip to content

Commit

Permalink
feat: 搜索分页
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Aug 12, 2023
1 parent 9872a3e commit 72b3a39
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 138 deletions.
1 change: 1 addition & 0 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"settings": "Settings",
"no-extension": "No installed extensions",
"no-result": "No relevant results",
"no-more-data": "No more data",
"cancel": "Cancel",
"confirm": "Confirm",
"close": "Close",
Expand Down
1 change: 1 addition & 0 deletions assets/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"settings": "设置",
"no-extension": "未安装任何扩展",
"no-result": "未找到相关结果",
"no-more-data": "没有更多数据了",
"cancel": "取消",
"confirm": "确定",
"close": "关闭",
Expand Down
3 changes: 0 additions & 3 deletions lib/pages/detail/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class DetailPageController extends GetxController {
);
showPlatformSnackbar(
context: cuurentContext,
title: '',
content: content,
severity: fluent.InfoBarSeverity.error,
);
Expand Down Expand Up @@ -186,7 +185,6 @@ class DetailPageController extends GetxController {
} catch (e) {
showPlatformSnackbar(
context: cuurentContext,
title: '',
content: e.toString().split('\n')[0],
severity: fluent.InfoBarSeverity.error,
);
Expand All @@ -205,7 +203,6 @@ class DetailPageController extends GetxController {
if (runtime.value == null) {
showPlatformSnackbar(
context: cuurentContext,
title: '',
content: FlutterI18n.translate(
cuurentContext,
'common.extension-missing',
Expand Down
10 changes: 7 additions & 3 deletions lib/pages/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,13 @@ class _DetailPageState extends State<DetailPage> {
Obx(
() {
if (c.tmdbDetail == null ||
c.tmdbDetail!.images.isEmpty) {
c.tmdbDetail!.backdrop == null) {
return const SizedBox();
}
final images = [
c.tmdbDetail!.backdrop!,
...c.tmdbDetail!.images
];
return fluent.Padding(
padding: const EdgeInsets.only(bottom: 16),
child: CardTile(
Expand All @@ -284,7 +288,7 @@ class _DetailPageState extends State<DetailPage> {
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
final image = c.tmdbDetail!.images[index];
final image = images[index];
final url = TmdbApi.getImageUrl(image);
if (url == null) {
return const SizedBox();
Expand All @@ -301,7 +305,7 @@ class _DetailPageState extends State<DetailPage> {
),
);
},
itemCount: c.tmdbDetail!.images.length,
itemCount: images.length,
),
),
),
Expand Down
10 changes: 7 additions & 3 deletions lib/pages/detail/widgets/detail_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ class DetailOverView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Obx(() {
if (c.tmdbDetail == null || c.tmdbDetail!.images.isEmpty) {
if (c.tmdbDetail == null || c.tmdbDetail!.backdrop == null) {
return const SizedBox();
}
final images = [c.tmdbDetail!.backdrop!, ...c.tmdbDetail!.images];
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand All @@ -41,7 +42,7 @@ class DetailOverView extends StatelessWidget {
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
final image = c.tmdbDetail!.images[index];
final image = images[index];
final url = TmdbApi.getImageUrl(image);
if (url == null) {
return const SizedBox();
Expand All @@ -58,7 +59,7 @@ class DetailOverView extends StatelessWidget {
),
);
},
itemCount: c.tmdbDetail!.images.length,
itemCount: images.length,
),
),
const SizedBox(height: 20),
Expand All @@ -68,6 +69,9 @@ class DetailOverView extends StatelessWidget {
Obx(
() => SelectableText(
c.tmdbDetail?.overview ?? c.detail?.desc ?? '',
style: const TextStyle(
height: 2,
),
),
),
const SizedBox(height: 20),
Expand Down
Loading

0 comments on commit 72b3a39

Please sign in to comment.