-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f5f89e
commit 0ed838b
Showing
7 changed files
with
114 additions
and
27 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...pps/shared/domain/src/commonMain/kotlin/network/bisq/mobile/domain/data/model/Settings.kt
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,14 @@ | ||
package network.bisq.mobile.domain.data.model | ||
|
||
open class Settings : BaseModel() { | ||
open var bisqUrl: String = "" | ||
open var isConnected: Boolean = false | ||
} | ||
|
||
interface SettingsFactory { | ||
fun createSettings(): Settings | ||
} | ||
|
||
class DefaultSettingsFactory : SettingsFactory { | ||
override fun createSettings() = Settings() | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...n/kotlin/network/bisq/mobile/presentation/ui/uicases/startup/TrustedNodeSetupPresenter.kt
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,50 @@ | ||
package network.bisq.mobile.presentation.ui.uicases.startup | ||
|
||
import androidx.navigation.NavController | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.IO | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.flow.collectLatest | ||
import network.bisq.mobile.domain.data.model.Settings | ||
import network.bisq.mobile.domain.data.repository.SettingsRepository | ||
import network.bisq.mobile.presentation.BasePresenter | ||
import network.bisq.mobile.presentation.ui.navigation.Routes | ||
import kotlinx.coroutines.delay | ||
|
||
class TrustedNodeSetupPresenter( | ||
private val navController: NavController, | ||
private val settingsRepository: SettingsRepository<Settings> | ||
) : BasePresenter(), ITrustedNodeSetupPresenter { | ||
|
||
private val _bisqUrl = MutableStateFlow("") | ||
override val bisqUrl: StateFlow<String> = _bisqUrl | ||
|
||
private val _isConnected = MutableStateFlow(false) | ||
override val isConnected: StateFlow<Boolean> = _isConnected | ||
|
||
override fun updateBisqUrl(newUrl: String) { | ||
_bisqUrl.value = newUrl | ||
} | ||
|
||
override fun testConnection(isTested: Boolean) { | ||
_isConnected.value = isTested | ||
|
||
CoroutineScope(Dispatchers.IO).launch { | ||
val updatedSettings = Settings().apply { | ||
bisqUrl = _bisqUrl.value | ||
isConnected = _isConnected.value | ||
} | ||
|
||
settingsRepository.update(updatedSettings) | ||
} | ||
} | ||
|
||
override fun navigateToNextScreen() { | ||
navController.navigate(Routes.TabContainer.name) { | ||
popUpTo(Routes.TrustedNodeSetup.name) { inclusive = true } | ||
} | ||
} | ||
} |
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