Skip to content

Commit

Permalink
Merge pull request #7 from ACINQ/feature/contentview-fix
Browse files Browse the repository at this point in the history
avoid InitView when a wallet exists
  • Loading branch information
SalomonBrys authored Sep 10, 2020
2 parents 8c5b8bf + b0acae3 commit 80c588b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
14 changes: 13 additions & 1 deletion phoenix-ios/phoenix-ios/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@ struct ContentView: MVIView {
NavigationView {
if model is Content.ModelIsInitialized {
HomeView()
} else {
} else if model is Content.ModelNeedInitialization {
InitView()
} else {
VStack {
// Maybe a better animation / transition screen ?
Image(systemName: "arrow.triangle.2.circlepath")
.imageScale(.large)
.rotationEffect(Angle(degrees: 360.0))
.animation(.easeIn)
}
.edgesIgnoringSafeArea(.all)
.navigationBarTitle("", displayMode: .inline)
.navigationBarHidden(true)
// Phoenix Loading View ?
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import org.kodein.di.DI
import org.kodein.di.instance

@OptIn(ExperimentalCoroutinesApi::class)
class AppContentController(di: DI) : AppController<Content.Model, Content.Intent>(di, Content.Model.NeedInitialization) {
class AppContentController(di: DI) : AppController<Content.Model, Content.Intent>(di, Content.Model.Waiting) {
private val walletManager: WalletManager by instance()

init {
launch {
walletManager.openWalletUpdatesSubscription().consumeEach {
if (walletManager.getWallet() != null) {
model { Content.Model.IsInitialized }
} else {
model { Content.Model.NeedInitialization }
walletManager.openWalletUpdatesSubscription().consumeEach {
model { Content.Model.IsInitialized }
return@consumeEach
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ typealias ContentController = MVI.Controller<Content.Model, Content.Intent>
object Content {

sealed class Model : MVI.Model() {
object Waiting : Model()
object IsInitialized : Model()
object NeedInitialization : Model()
}
Expand Down

0 comments on commit 80c588b

Please sign in to comment.