This commit is contained in:
@ -32,8 +32,9 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> {
|
||||
PageController? _pageController;
|
||||
final MediaController mediaController = Get.find<MediaController>();
|
||||
final AuthController authController = Get.find<AuthController>();
|
||||
final _currentIndex = 0.obs;
|
||||
final _mediaSaverChannel = const MethodChannel('MediaShit');
|
||||
final RxInt _currentIndex = 0.obs;
|
||||
final MethodChannel _mediaSaverChannel = const MethodChannel('MediaShit');
|
||||
final Map<int, bool> _expandedTags = {};
|
||||
|
||||
bool _isLoading = true;
|
||||
bool _itemNotFound = false;
|
||||
@ -105,7 +106,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> {
|
||||
void _onPageChanged(int idx) {
|
||||
if (idx != _currentIndex.value) {
|
||||
_currentIndex.value = idx;
|
||||
final item = mediaController.items[idx];
|
||||
final MediaItem item = mediaController.items[idx];
|
||||
if (item.mime.startsWith('image/') && !_readyItemIds.contains(item.id)) {
|
||||
setState(() => _readyItemIds.add(item.id));
|
||||
}
|
||||
@ -224,46 +225,52 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> {
|
||||
itemBuilder: (context, index) {
|
||||
final MediaItem item = mediaController.items[index];
|
||||
final bool isReady = _readyItemIds.contains(item.id);
|
||||
final bool areTagsExpanded = _expandedTags[item.id] ?? false;
|
||||
final List<Tag> allTags = item.tags ?? [];
|
||||
final bool hasMoreTags = allTags.length > 5;
|
||||
final List<Tag> tagsToShow = areTagsExpanded
|
||||
? allTags
|
||||
: allTags.take(5).toList();
|
||||
|
||||
return Scaffold(
|
||||
endDrawer: EndDrawer(),
|
||||
endDrawerEnableOpenDragGesture:
|
||||
mediaController.drawerSwipeEnabled.value,
|
||||
appBar: AppBar(
|
||||
title: Text('f0ck #${item.id}'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.fullscreen),
|
||||
onPressed: () {
|
||||
Get.to(
|
||||
FullScreenMediaView(item: item),
|
||||
fullscreenDialog: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.download),
|
||||
onPressed: () async {
|
||||
await _downloadMedia(item);
|
||||
},
|
||||
),
|
||||
PopupMenuButton<ShareAction>(
|
||||
onSelected: (value) => _handleShareAction(value, item),
|
||||
itemBuilder: (context) => _shareMenuItems,
|
||||
icon: const Icon(Icons.share),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: const Icon(Icons.menu),
|
||||
return Obx(
|
||||
() => Scaffold(
|
||||
endDrawer: EndDrawer(),
|
||||
endDrawerEnableOpenDragGesture:
|
||||
mediaController.drawerSwipeEnabled.value,
|
||||
appBar: AppBar(
|
||||
title: Text('f0ck #${item.id}'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.fullscreen),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openEndDrawer();
|
||||
Get.to(
|
||||
FullScreenMediaView(item: item),
|
||||
fullscreenDialog: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
IconButton(
|
||||
icon: const Icon(Icons.download),
|
||||
onPressed: () async {
|
||||
await _downloadMedia(item);
|
||||
},
|
||||
),
|
||||
PopupMenuButton<ShareAction>(
|
||||
onSelected: (value) => _handleShareAction(value, item),
|
||||
itemBuilder: (context) => _shareMenuItems,
|
||||
icon: const Icon(Icons.share),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) => IconButton(
|
||||
icon: const Icon(Icons.menu),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openEndDrawer();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
AnimatedBuilder(
|
||||
@ -281,55 +288,78 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> {
|
||||
() => _buildMedia(item, index == _currentIndex.value),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (isReady)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: 6.0,
|
||||
runSpacing: 4.0,
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
...item.tags?.map(
|
||||
(tag) => ActionTag(
|
||||
tag,
|
||||
(tag.tag == 'sfw' || tag.tag == 'nsfw')
|
||||
? (onTagTap) => {}
|
||||
: (onTagTap) {
|
||||
mediaController.setTag(onTagTap);
|
||||
Get.offAllNamed('/');
|
||||
},
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => mediaController.hideVideoControls(),
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Visibility(
|
||||
visible: isReady,
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Wrap(
|
||||
spacing: 6.0,
|
||||
runSpacing: 4.0,
|
||||
alignment: WrapAlignment.center,
|
||||
children: [
|
||||
...tagsToShow.map(
|
||||
(tag) => ActionTag(
|
||||
tag,
|
||||
(tag.tag == 'sfw' || tag.tag == 'nsfw')
|
||||
? (onTagTap) => {}
|
||||
: (onTagTap) {
|
||||
mediaController.setTag(
|
||||
onTagTap,
|
||||
);
|
||||
Get.offAllNamed('/');
|
||||
},
|
||||
),
|
||||
),
|
||||
) ??
|
||||
[],
|
||||
],
|
||||
),
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: authController.isLoggedIn,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 20.0),
|
||||
child: FavoriteSection(
|
||||
item: item,
|
||||
index: index,
|
||||
],
|
||||
),
|
||||
),
|
||||
if (hasMoreTags)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
setState(
|
||||
() => _expandedTags[item.id] =
|
||||
!areTagsExpanded,
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
areTagsExpanded
|
||||
? 'Weniger anzeigen'
|
||||
: 'Alle ${allTags.length} Tags anzeigen',
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: authController.isLoggedIn,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 20.0),
|
||||
child: FavoriteSection(
|
||||
item: item,
|
||||
index: index,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
const SafeArea(child: SizedBox.shrink()),
|
||||
],
|
||||
),
|
||||
persistentFooterButtons: mediaController.tag.value != null
|
||||
? [TagFooter()]
|
||||
: null,
|
||||
),
|
||||
persistentFooterButtons: mediaController.tag.value != null
|
||||
? [TagFooter()]
|
||||
: null,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user