mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Refactor
This commit is contained in:
parent
3eb634f454
commit
76d122783f
1 changed files with 23 additions and 22 deletions
|
@ -73,13 +73,34 @@ class _ViewerState extends State<Viewer> with TickerProviderStateMixin {
|
||||||
build(BuildContext context) {
|
build(BuildContext context) {
|
||||||
return AppTheme(
|
return AppTheme(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: Builder(builder: (context) => _buildContent(context)),
|
body: Builder(
|
||||||
|
builder: (context) =>
|
||||||
|
kIsWeb ? _buildWebContent(context) : _buildContent(context)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildWebContent(BuildContext context) {
|
||||||
|
assert(kIsWeb);
|
||||||
|
// support switching pages with keyboard on web
|
||||||
|
return RawKeyboardListener(
|
||||||
|
onKey: (ev) {
|
||||||
|
if (!_canSwitchPage()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ev.isKeyPressed(LogicalKeyboardKey.arrowLeft)) {
|
||||||
|
_switchToLeftImage();
|
||||||
|
} else if (ev.isKeyPressed(LogicalKeyboardKey.arrowRight)) {
|
||||||
|
_switchToRightImage();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focusNode: _pageFocus,
|
||||||
|
child: _buildContent(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildContent(BuildContext context) {
|
Widget _buildContent(BuildContext context) {
|
||||||
Widget content = Listener(
|
return Listener(
|
||||||
onPointerDown: (event) {
|
onPointerDown: (event) {
|
||||||
++_finger;
|
++_finger;
|
||||||
if (_finger >= 2 && _canZoom()) {
|
if (_finger >= 2 && _canZoom()) {
|
||||||
|
@ -133,26 +154,6 @@ class _ViewerState extends State<Viewer> with TickerProviderStateMixin {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// support switching pages with keyboard on web
|
|
||||||
if (kIsWeb) {
|
|
||||||
content = RawKeyboardListener(
|
|
||||||
onKey: (ev) {
|
|
||||||
if (!_canSwitchPage()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ev.isKeyPressed(LogicalKeyboardKey.arrowLeft)) {
|
|
||||||
_switchToLeftImage();
|
|
||||||
} else if (ev.isKeyPressed(LogicalKeyboardKey.arrowRight)) {
|
|
||||||
_switchToRightImage();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
focusNode: _pageFocus,
|
|
||||||
child: content,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildNavigationButtons(BuildContext context) {
|
List<Widget> _buildNavigationButtons(BuildContext context) {
|
||||||
|
|
Loading…
Reference in a new issue