batch download

This commit is contained in:
wgh19
2024-05-15 18:05:45 +08:00
parent 9760397f28
commit 7e71b5b1ce
9 changed files with 258 additions and 42 deletions

View File

@@ -1,5 +1,6 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:pixes/components/batch_download.dart';
import 'package:pixes/components/segmented_button.dart';
import 'package:pixes/components/title_bar.dart';
import 'package:pixes/foundation/app.dart';
@@ -34,19 +35,25 @@ class _BookMarkedArtworkPageState extends State<BookMarkedArtworkPage>{
Widget buildTab() {
return TitleBar(
title: "Bookmarks".tl,
action: SegmentedButton(
options: [
SegmentedButtonOption("public", "Public".tl),
SegmentedButtonOption("private", "Private".tl),
action: Row(
children: [
BatchDownloadButton(request: () => Network().getBookmarkedIllusts(restrict)),
const SizedBox(width: 8,),
SegmentedButton(
options: [
SegmentedButtonOption("public", "Public".tl),
SegmentedButtonOption("private", "Private".tl),
],
onPressed: (key) {
if(key != restrict) {
setState(() {
restrict = key;
});
}
},
value: restrict,
)
],
onPressed: (key) {
if(key != restrict) {
setState(() {
restrict = key;
});
}
},
value: restrict,
),
);
}

View File

@@ -66,6 +66,7 @@ class _DownloadingPageState extends State<DownloadingPage> {
controller[task.illust.id.toString()] ??= FlyoutController();
return Card(
margin: const EdgeInsets.only(bottom: 8),
padding: const EdgeInsets.symmetric(vertical: 8),
child: SizedBox(
height: 96,

View File

@@ -4,6 +4,7 @@ import 'package:pixes/components/title_bar.dart';
import 'package:pixes/foundation/app.dart';
import 'package:pixes/utils/translation.dart';
import '../components/batch_download.dart';
import '../components/illust_widget.dart';
import '../components/loading.dart';
import '../components/segmented_button.dart';
@@ -34,20 +35,26 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
Widget buildTab() {
return TitleBar(
title: "Following".tl,
action: SegmentedButton(
options: [
SegmentedButtonOption("all", "All".tl),
SegmentedButtonOption("public", "Public".tl),
SegmentedButtonOption("private", "Private".tl),
action: Row(
children: [
BatchDownloadButton(request: () => Network().getFollowingArtworks(restrict)),
const SizedBox(width: 8,),
SegmentedButton(
options: [
SegmentedButtonOption("all", "All".tl),
SegmentedButtonOption("public", "Public".tl),
SegmentedButtonOption("private", "Private".tl),
],
onPressed: (key) {
if(key != restrict) {
setState(() {
restrict = key;
});
}
},
value: restrict,
)
],
onPressed: (key) {
if(key != restrict) {
setState(() {
restrict = key;
});
}
},
value: restrict,
),
);
}

View File

@@ -3,8 +3,10 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:pixes/foundation/app.dart';
import 'package:pixes/utils/translation.dart';
import '../components/batch_download.dart';
import '../components/illust_widget.dart';
import '../components/loading.dart';
import '../components/title_bar.dart';
import '../network/network.dart';
class RankingPage extends StatefulWidget {
@@ -48,12 +50,12 @@ class _RankingPageState extends State<RankingPage> {
}
Widget buildHeader() {
return SizedBox(
child: Row(
return TitleBar(
title: "Ranking".tl,
action: Row(
children: [
Text("Ranking".tl, style: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold),),
const Spacer(),
BatchDownloadButton(request: () => Network().getRanking(type)),
const SizedBox(width: 8,),
DropDownButton(
title: Text(types[type]!),
items: types.entries.map((e) => MenuFlyoutItem(
@@ -66,8 +68,8 @@ class _RankingPageState extends State<RankingPage> {
)).toList(),
)
],
)
).padding(const EdgeInsets.symmetric(vertical: 8, horizontal: 16));
),
);
}
}

View File

@@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:pixes/appdata.dart';
import 'package:pixes/components/batch_download.dart';
import 'package:pixes/components/loading.dart';
import 'package:pixes/components/md.dart';
import 'package:pixes/foundation/app.dart';
@@ -32,7 +33,12 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
slivers: [
buildUser(),
buildInformation(),
SliverToBoxAdapter(child: buildHeader("Artworks"),),
SliverToBoxAdapter(
child: buildHeader(
"Artworks",
action: BatchDownloadButton(
request: () => Network().getUserIllusts(widget.id))
),),
_UserArtworks(data.id.toString(), key: ValueKey(data.id),),
SliverPadding(padding: EdgeInsets.only(bottom: context.padding.bottom)),
],
@@ -146,13 +152,21 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
);
}
Widget buildHeader(String title) {
Widget buildHeader(String title, {Widget? action}) {
return SizedBox(
width: double.infinity,
child: Text(
title,
style: const TextStyle(fontWeight: FontWeight.w600),
).toAlign(Alignment.centerLeft)).paddingLeft(16).paddingVertical(4);
height: 38,
child: Row(
children: [
Text(
title,
style: const TextStyle(fontWeight: FontWeight.w600),
).toAlign(Alignment.centerLeft),
const Spacer(),
if(action != null)
action.toAlign(Alignment.centerRight)
],
).paddingHorizontal(16)).paddingTop(8);
}
Widget buildInformation() {
@@ -181,7 +195,6 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
buildItem(icon: MdIcons.location_city_outlined, title: "Region", content: data!.region),
buildItem(icon: MdIcons.work_outline, title: "Job".tl, content: data!.job),
buildItem(icon: MdIcons.person_2_outlined, title: "Gender".tl, content: data!.gender),
const SizedBox(height: 8,),
buildHeader("Social Network".tl),
buildItem(title: "Webpage",
content: data!.webpage,