Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ui/screens/timeline/timeline_screen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'dart:async';
import 'dart:math' as Math;
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:wonders/common_libs.dart';
import 'package:wonders/logic/common/animate_utils.dart';
import 'package:wonders/logic/common/debouncer.dart';
Expand Down
47 changes: 27 additions & 20 deletions lib/ui/screens/timeline/widgets/_scrolling_viewport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,35 @@ class _ScalingViewportState extends State<_ScrollingViewport> {
scheduleMicrotask(controller._handleResize);
}
_prevSize = context.mq.size;
return GestureDetector(
// Handle pinch to zoom
onScaleUpdate: controller._handleScaleUpdate,
onScaleStart: controller._handleScaleStart,
behavior: HitTestBehavior.translucent,
// Fade in entire view when first shown
child: Stack(
children: [
// Main content area
_buildScrollingArea(context).maybeAnimate().fadeIn(),
return Listener(
onPointerSignal: (PointerSignalEvent e) {
if (HardwareKeyboard.instance.isControlPressed) {
controller._handleScaleUpdateMouse(((e as PointerScaleEvent).scale - 1) * 0.25);
}
},
child: GestureDetector(
// Handle pinch to zoom
onScaleUpdate: controller._handleScaleUpdate,
onScaleStart: controller._handleScaleStart,
behavior: HitTestBehavior.translucent,
// Fade in entire view when first shown
child: Stack(
children: [
// Main content area
_buildScrollingArea(context).maybeAnimate().fadeIn(),

// Dashed line with a year that changes as we scroll
IgnorePointerKeepSemantics(
child: AnimatedBuilder(
animation: controller.scroller,
builder: (_, __) {
return _DashedDividerWithYear(controller.calculateYearFromScrollPos());
},
// Dashed line with a year that changes as we scroll
IgnorePointerKeepSemantics(
child: AnimatedBuilder(
animation: controller.scroller,
builder: (_, __) {
return _DashedDividerWithYear(controller.calculateYearFromScrollPos());
},
),
),
),
],
),
],
),
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class _ScrollingViewportController extends ChangeNotifier {
setZoom(details.scale * _zoomOnScaleStart);
}

void _handleScaleUpdateMouse(double scale) {
setZoom( Math.max(0, Math.min(1, _zoom + scale)) );
}

/// Maintain current yr when the app changes size
void _handleResize() => jumpToYear(_currentYr.value);
}