forked from status-im/status-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@desktop/wallet): fix switch accounts after opening collectible d…
…etails Moved logic for CollectibleDetailView to Nim module.
- Loading branch information
Showing
20 changed files
with
375 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/app/modules/main/wallet_section/collectibles/current_collectible/controller.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import io_interface | ||
|
||
import ../collectibles/module as collectibles_module | ||
import ../collections/module as collections_module | ||
|
||
type | ||
Controller* = ref object of RootObj | ||
delegate: io_interface.AccessInterface | ||
collectiblesModule: collectibles_module.AccessInterface | ||
collectionsModule: collections_module.AccessInterface | ||
|
||
proc newController*( | ||
delegate: io_interface.AccessInterface, | ||
collectiblesModule: collectibles_module.AccessInterface, | ||
collectionsModule: collections_module.AccessInterface | ||
): Controller = | ||
result = Controller() | ||
result.delegate = delegate | ||
result.collectiblesModule = collectiblesModule | ||
result.collectionsModule = collectionsModule | ||
|
||
proc delete*(self: Controller) = | ||
discard | ||
|
||
proc init*(self: Controller) = | ||
discard | ||
|
||
proc update*(self: Controller, slug: string, id: int) = | ||
self.delegate.setData(self.collectionsModule.getCollection(slug), self.collectiblesModule.getCollectible(slug, id)) |
27 changes: 27 additions & 0 deletions
27
src/app/modules/main/wallet_section/collectibles/current_collectible/io_interface.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import ../collections/item as collection_item | ||
import ../collectibles/item as collectible_item | ||
|
||
type | ||
AccessInterface* {.pure inheritable.} = ref object of RootObj | ||
## Abstract class for any input/interaction with this module. | ||
|
||
method delete*(self: AccessInterface) {.base.} = | ||
raise newException(ValueError, "No implementation available") | ||
|
||
method load*(self: AccessInterface) {.base.} = | ||
raise newException(ValueError, "No implementation available") | ||
|
||
method isLoaded*(self: AccessInterface): bool {.base.} = | ||
raise newException(ValueError, "No implementation available") | ||
|
||
method update*(self: AccessInterface, slug: string, id: int) {.base.} = | ||
raise newException(ValueError, "No implementation available") | ||
|
||
method setData*(self: AccessInterface, collection: collection_item.Item, collectible: collectible_item.Item) {.base.} = | ||
raise newException(ValueError, "No implementation available") | ||
|
||
# View Delegate Interface | ||
# Delegate for the view must be declared here due to use of QtObject and multi | ||
# inheritance, which is not well supported in Nim. | ||
method viewDidLoad*(self: AccessInterface) {.base.} = | ||
raise newException(ValueError, "No implementation available") |
54 changes: 54 additions & 0 deletions
54
src/app/modules/main/wallet_section/collectibles/current_collectible/module.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import NimQml, sequtils, sugar | ||
|
||
import ../../../../../global/global_singleton | ||
|
||
import ./io_interface, ./view, ./controller | ||
import ../io_interface as delegate_interface | ||
import ../collectibles/module as collectibles_module | ||
import ../collections/module as collections_module | ||
|
||
import ../collections/item as collection_item | ||
import ../collectibles/item as collectible_item | ||
|
||
export io_interface | ||
|
||
type | ||
Module* = ref object of io_interface.AccessInterface | ||
delegate: delegate_interface.AccessInterface | ||
view: View | ||
controller: Controller | ||
moduleLoaded: bool | ||
currentAccountIndex: int | ||
|
||
proc newModule*( | ||
delegate: delegate_interface.AccessInterface, | ||
collectionsModule: collections_module.AccessInterface, | ||
collectiblesModule: collectibles_module.AccessInterface, | ||
): Module = | ||
result = Module() | ||
result.delegate = delegate | ||
result.view = newView(result) | ||
result.controller = newController(result, collectiblesModule, collectionsModule) | ||
result.moduleLoaded = false | ||
|
||
method delete*(self: Module) = | ||
self.view.delete | ||
|
||
method load*(self: Module) = | ||
singletonInstance.engine.setRootContextProperty("walletSectionCollectibleCurrent", newQVariant(self.view)) | ||
|
||
self.controller.init() | ||
self.view.load() | ||
|
||
method isLoaded*(self: Module): bool = | ||
return self.moduleLoaded | ||
|
||
method viewDidLoad*(self: Module) = | ||
self.moduleLoaded = true | ||
self.delegate.currentCollectibleModuleDidLoad() | ||
|
||
method update*(self: Module, slug: string, id: int) = | ||
self.controller.update(slug, id) | ||
|
||
method setData*(self: Module, collection: collection_item.Item, collectible: collectible_item.Item) = | ||
self.view.setData(collection, collectible) |
Oops, something went wrong.