aboutsummaryrefslogtreecommitdiff
path: root/spike/settings/source/SpikeDelegate.mc
blob: 94b3ece29344801a4a21e4fcd14136f8962ae6d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Author:  cirakg & claude ai
// Summary: Input of the spike screen: UP/DOWN or swipes scroll, START/tap jumps back to the top.

import Toybox.Lang;
import Toybox.WatchUi;

class SpikeDelegate extends WatchUi.BehaviorDelegate {

    // Lines moved per button press or swipe.
    private const SCROLL_STEP = 3;
    // Large enough to reach the first line from anywhere.
    private const TO_TOP = -1000;

    private var _view as SpikeView;

    function initialize(view as SpikeView) {
        BehaviorDelegate.initialize();
        _view = view;
    }

    function onNextPage() as Boolean {
        _view.scroll(SCROLL_STEP);
        return true;
    }

    function onPreviousPage() as Boolean {
        _view.scroll(-SCROLL_STEP);
        return true;
    }

    function onSelect() as Boolean {
        _view.scroll(TO_TOP);
        return true;
    }
}