From 6550975a4e7b26c55210106162ff58f174507da1 Mon Sep 17 00:00:00 2001 From: shmyga Date: Mon, 17 Feb 2020 23:09:40 +0300 Subject: [PATCH] [update] start frame buttons state --- src/haxe/ru/m/puzzlez/view/StartFrame.hx | 12 ++++++++++-- src/haxe/ru/m/puzzlez/view/StartFrame.yaml | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/haxe/ru/m/puzzlez/view/StartFrame.hx b/src/haxe/ru/m/puzzlez/view/StartFrame.hx index 3ea0338..2a2aaef 100644 --- a/src/haxe/ru/m/puzzlez/view/StartFrame.hx +++ b/src/haxe/ru/m/puzzlez/view/StartFrame.hx @@ -34,9 +34,17 @@ import ru.m.puzzlez.storage.ImageStorage; sources.data = data; } + private function refresh():Void { + var startedCount = gameStorage.list(STARTED).length; + var completeCount = gameStorage.list(COMPLETE).length; + loadButton.text = 'Resume (${startedCount})'; + completeButton.text = 'Complete (${completeCount})'; + loadButton.disabled = startedCount == 0; + completeButton.disabled = completeCount == 0; + } + override public function onShow(data:Dynamic):Void { - loadButton.text = 'Resume (${gameStorage.list(STARTED).length})'; - completeButton.text = 'Complete (${gameStorage.list(COMPLETE).length})'; + refresh(); } private function sourceViewFactory(index:Int, source:ImageListSource):ButtonView { diff --git a/src/haxe/ru/m/puzzlez/view/StartFrame.yaml b/src/haxe/ru/m/puzzlez/view/StartFrame.yaml index 07ccd6c..0f3ceb1 100644 --- a/src/haxe/ru/m/puzzlez/view/StartFrame.yaml +++ b/src/haxe/ru/m/puzzlez/view/StartFrame.yaml @@ -37,6 +37,7 @@ views: style: button.red text: Clean +onPress: ~clean() + visible: false - $type: haxework.view.form.LabelView text: $r:text:version geometry.position: absolute