From b3a4adce68f5b479d7a3351d76eff63359318bf9 Mon Sep 17 00:00:00 2001 From: shmyga Date: Wed, 11 Mar 2020 21:51:55 +0300 Subject: [PATCH] [improve] add LoadingWrapper to GameListFrame --- src/haxe/ru/m/puzzlez/view/GameListFrame.hx | 13 ++++++++++--- src/haxe/ru/m/puzzlez/view/GameListFrame.yaml | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/haxe/ru/m/puzzlez/view/GameListFrame.hx b/src/haxe/ru/m/puzzlez/view/GameListFrame.hx index 4970cb7..a8c184b 100644 --- a/src/haxe/ru/m/puzzlez/view/GameListFrame.hx +++ b/src/haxe/ru/m/puzzlez/view/GameListFrame.hx @@ -17,6 +17,7 @@ import ru.m.puzzlez.view.PuzzleImageView; @:view("images") var imagesView:ActionDataView; @:view("pages") var pagesView:DataView; + private var loading:LoadingWrapper; @:provide var switcher:FrameSwitcher; @:provide var storage:GameStorage; @@ -26,15 +27,16 @@ import ru.m.puzzlez.view.PuzzleImageView; private var data(default, set):DataPage; - private function set_data(value) { + private function set_data(value:DataPage):DataPage { data = value; imagesView.data = data.data; - pagesView.data = [for (i in 0...Std.int(data.total / data.page.count) + 1) i]; + pagesView.data = [for (i in 0...Std.int((data.total - 1) / data.page.count) + 1) i]; return data; } public function new() { super(ID); + loading = new LoadingWrapper(imagesView); page = {index: 0, count: 6, order: [{key: "date", reverse: true}]}; } @@ -56,7 +58,12 @@ import ru.m.puzzlez.view.PuzzleImageView; } private function refresh():Void { - storage.getIndexPage(page).then(data -> this.data = data); + data = { + page: page, + total: 0, + data: [], + }; + loading.promise = storage.getIndexPage(page).then(data -> this.data = data); } private function onAction(imageId:ImageId, action:Action):Void { diff --git a/src/haxe/ru/m/puzzlez/view/GameListFrame.yaml b/src/haxe/ru/m/puzzlez/view/GameListFrame.yaml index 32d8baf..58f23b8 100644 --- a/src/haxe/ru/m/puzzlez/view/GameListFrame.yaml +++ b/src/haxe/ru/m/puzzlez/view/GameListFrame.yaml @@ -5,6 +5,7 @@ views: $type: haxework.view.data.ActionDataView layout: $type: haxework.view.layout.TailLayout + rowSize: 3 margin: 5 vAlign: middle geometry.stretch: true