Skip to content

Commit

Permalink
chore: Follow up imageviewer
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Jan 6, 2025
1 parent b2131e6 commit 1ef0289
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
19 changes: 19 additions & 0 deletions lib/pages/image_viewer/image_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import 'package:matrix/matrix.dart';

import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/image_viewer/image_viewer_view.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/show_scaffold_dialog.dart';
Expand Down Expand Up @@ -44,6 +45,24 @@ class ImageViewerController extends State<ImageViewer> {

late final List<Event> allEvents;

void prevImage() {
setState(() {
pageController.previousPage(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
);
});
}

void nextImage() {
setState(() {
pageController.nextPage(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
);
});
}

int get _index => pageController.page?.toInt() ?? 0;

Event get currentEvent => allEvents[_index];
Expand Down
11 changes: 2 additions & 9 deletions lib/pages/image_viewer/image_viewer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';

import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/hover_builder.dart';
import 'package:fluffychat/widgets/mxc_image.dart';
Expand Down Expand Up @@ -104,10 +103,7 @@ class ImageViewerView extends StatelessWidget {
style: iconButtonStyle,
tooltip: L10n.of(context).previous,
icon: const Icon(Icons.chevron_left_outlined),
onPressed: () => controller.pageController.previousPage(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
),
onPressed: controller.prevImage,
),
),
),
Expand All @@ -120,10 +116,7 @@ class ImageViewerView extends StatelessWidget {
style: iconButtonStyle,
tooltip: L10n.of(context).next,
icon: const Icon(Icons.chevron_right_outlined),
onPressed: () => controller.pageController.nextPage(
duration: FluffyThemes.animationDuration,
curve: FluffyThemes.animationCurve,
),
onPressed: controller.nextImage,
),
),
),
Expand Down

0 comments on commit 1ef0289

Please sign in to comment.