mirror of
https://gitlab.com/mysocialportal/relatica
synced 2024-10-18 13:33:32 +00:00
Merge branch 'attachment-viewing-updates' of gitlab.com:mysocialportal/relatica into attachment-viewing-updates
This commit is contained in:
commit
e24aceaeeb
2 changed files with 42 additions and 23 deletions
|
@ -29,7 +29,7 @@ void main() async {
|
|||
WidgetsFlutterBinding.ensureInitialized();
|
||||
MediaKit.ensureInitialized();
|
||||
// await dotenv.load(fileName: '.env');
|
||||
const enablePreview = true;
|
||||
const enablePreview = false;
|
||||
Logger.root.level = Level.FINER;
|
||||
Logger.root.onRecord.listen((event) {
|
||||
final logName = event.loggerName.isEmpty ? 'ROOT' : event.loggerName;
|
||||
|
|
|
@ -37,6 +37,25 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
currentIndex = widget.initialIndex;
|
||||
}
|
||||
|
||||
void nextAttachment() {
|
||||
if (currentIndex >= widget.attachments.length - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
currentIndex++;
|
||||
});
|
||||
}
|
||||
|
||||
void previousAttachment() {
|
||||
if (currentIndex < 1) {
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
currentIndex--;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> saveImage(
|
||||
BuildContext context,
|
||||
MediaAttachment attachment,
|
||||
|
@ -74,7 +93,11 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final currentAttachment = widget.attachments[currentIndex];
|
||||
final height = MediaQuery.of(context).size.height;
|
||||
final width = MediaQuery.of(context).size.width;
|
||||
final height = MediaQuery.of(context).size.height * 0.9;
|
||||
final descriptionHeightPct = widget.attachments.isEmpty ? 0.0 : 0.1;
|
||||
final mediaHeight = height * (1 - descriptionHeightPct);
|
||||
final descriptionHeight = height * descriptionHeightPct;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
actions: [
|
||||
|
@ -89,22 +112,23 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
SizedBox(
|
||||
width: width,
|
||||
height: mediaHeight,
|
||||
child: InteractiveViewer(
|
||||
maxScale: 10.0,
|
||||
scaleFactor: 400,
|
||||
child: LoginAwareCachedNetworkImage(
|
||||
imageUrl:
|
||||
widget.attachments[currentIndex].uri.toString()),
|
||||
imageUrl: currentAttachment.uri.toString()),
|
||||
),
|
||||
),
|
||||
if (currentAttachment.description.isNotEmpty)
|
||||
buildTextArea(currentAttachment),
|
||||
buildTextArea(currentAttachment, descriptionHeight),
|
||||
],
|
||||
),
|
||||
if (widget.attachments.length > 1) ...[
|
||||
Positioned(
|
||||
bottom: height * 0.5,
|
||||
bottom: mediaHeight * 0.5,
|
||||
child: Opacity(
|
||||
opacity: 0.8,
|
||||
child: currentIndex < 1
|
||||
|
@ -113,18 +137,14 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
color: Colors.black,
|
||||
child: IconButton(
|
||||
color: Colors.white,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
currentIndex--;
|
||||
});
|
||||
},
|
||||
onPressed: previousAttachment,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: height * 0.5,
|
||||
bottom: mediaHeight * 0.5,
|
||||
right: 0.0,
|
||||
child: Opacity(
|
||||
opacity: 0.8,
|
||||
|
@ -134,11 +154,7 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
color: Colors.black,
|
||||
child: IconButton(
|
||||
color: Colors.white,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
currentIndex++;
|
||||
});
|
||||
},
|
||||
onPressed: nextAttachment,
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
),
|
||||
),
|
||||
|
@ -151,10 +167,9 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
Widget buildTextArea(MediaAttachment attachment) {
|
||||
final height = MediaQuery.of(context).size.height * 0.1;
|
||||
Widget buildTextArea(MediaAttachment attachment, double height) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: SizedBox(
|
||||
height: height,
|
||||
child: attachment.description.isEmpty
|
||||
|
@ -163,8 +178,12 @@ class _MediaViewerScreenState extends State<MediaViewerScreen> {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Text(attachment.description),
|
||||
child: Scrollbar(
|
||||
controller: ScrollController(),
|
||||
thumbVisibility: true,
|
||||
child: SingleChildScrollView(
|
||||
child: Text(attachment.description),
|
||||
),
|
||||
)),
|
||||
IconButton(
|
||||
onPressed: () async {
|
||||
|
|
Loading…
Reference in a new issue