#1113 viewer: long descriptions are scrollable when overlay is expanded by tap
This commit is contained in:
parent
867fb95426
commit
554e1faf88
2 changed files with 53 additions and 6 deletions
|
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Viewer: display more items in tag/copy/move quick action choosers
|
- Viewer: display more items in tag/copy/move quick action choosers
|
||||||
|
- Viewer: long descriptions are scrollable when overlay is expanded by tap
|
||||||
- Collection: sort by duration
|
- Collection: sort by duration
|
||||||
- Map: open external map app from map views
|
- Map: open external map app from map views
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class OverlayRowExpander extends StatelessWidget {
|
class OverlayRowExpander extends StatefulWidget {
|
||||||
final ValueNotifier<bool> expandedNotifier;
|
final ValueNotifier<bool> expandedNotifier;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
|
@ -10,24 +11,69 @@ class OverlayRowExpander extends StatelessWidget {
|
||||||
required this.child,
|
required this.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<OverlayRowExpander> createState() => _OverlayRowExpanderState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OverlayRowExpanderState extends State<OverlayRowExpander> {
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(covariant OverlayRowExpander oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (oldWidget.child != widget.child) {
|
||||||
|
if (_scrollController.hasClients && _scrollController.positions.every((v) => v.hasContentDimensions)) {
|
||||||
|
_scrollController.jumpTo(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ValueListenableBuilder<bool>(
|
return ValueListenableBuilder<bool>(
|
||||||
valueListenable: expandedNotifier,
|
valueListenable: widget.expandedNotifier,
|
||||||
builder: (context, expanded, child) {
|
builder: (context, expanded, child) {
|
||||||
final parent = DefaultTextStyle.of(context);
|
final parent = DefaultTextStyle.of(context);
|
||||||
return DefaultTextStyle(
|
child = DefaultTextStyle(
|
||||||
key: key,
|
|
||||||
style: parent.style,
|
style: parent.style,
|
||||||
textAlign: parent.textAlign,
|
textAlign: parent.textAlign,
|
||||||
softWrap: expanded,
|
softWrap: expanded,
|
||||||
overflow: parent.overflow,
|
overflow: parent.overflow,
|
||||||
maxLines: expanded ? 16 : 1,
|
maxLines: expanded ? null : 1,
|
||||||
textWidthBasis: parent.textWidthBasis,
|
textWidthBasis: parent.textWidthBasis,
|
||||||
child: child!,
|
child: child!,
|
||||||
);
|
);
|
||||||
|
if (expanded) {
|
||||||
|
child = ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxHeight: context.select<MediaQueryData, double>((mq) => mq.size.height / 5),
|
||||||
|
),
|
||||||
|
child: MediaQuery.removePadding(
|
||||||
|
// remove padding so that scroll bar is consistent with the scroll view
|
||||||
|
context: context,
|
||||||
|
removeTop: true,
|
||||||
|
removeBottom: true,
|
||||||
|
child: Scrollbar(
|
||||||
|
controller: _scrollController,
|
||||||
|
thumbVisibility: true,
|
||||||
|
radius: const Radius.circular(16),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
controller: _scrollController,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return child;
|
||||||
},
|
},
|
||||||
child: child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue