-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- connect new repository to TopBar navigation so that it can read us…
…er saved profile. Added same code for iOS though not tested yet
- Loading branch information
Showing
13 changed files
with
117 additions
and
16 deletions.
There are no files selected for viewing
5 changes: 2 additions & 3 deletions
5
shared/domain/src/commonMain/kotlin/network/bisq/mobile/domain/data/model/User.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 |
---|---|---|
@@ -1,10 +1,9 @@ | ||
package network.bisq.mobile.domain.data.model | ||
|
||
import kotlinx.serialization.Serializable | ||
import network.bisq.mobile.domain.PlatformImage | ||
|
||
/** | ||
* | ||
*/ | ||
@Serializable | ||
open class User: BaseModel() { | ||
var uniqueAvatar: PlatformImage? = null | ||
} |
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
9 changes: 9 additions & 0 deletions
9
...idMain/kotlin/network/bisq/mobile/presentation/ui/components/atoms/icons/Icons.android.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,9 @@ | ||
package network.bisq.mobile.presentation.ui.components.atoms.icons | ||
|
||
import androidx.compose.ui.graphics.painter.BitmapPainter | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import network.bisq.mobile.domain.PlatformImage | ||
|
||
actual fun rememberPlatformImagePainter(platformImage: PlatformImage): Painter { | ||
return BitmapPainter(platformImage.bitmap) | ||
} |
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
39 changes: 39 additions & 0 deletions
39
...onMain/kotlin/network/bisq/mobile/presentation/ui/components/molecules/TopBarPresenter.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,39 @@ | ||
package network.bisq.mobile.presentation.ui.components.molecules | ||
|
||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.launch | ||
import network.bisq.mobile.domain.PlatformImage | ||
import network.bisq.mobile.domain.data.repository.UserRepository | ||
import network.bisq.mobile.presentation.BasePresenter | ||
import network.bisq.mobile.presentation.MainPresenter | ||
|
||
open class TopBarPresenter( | ||
private val userRepository: UserRepository, | ||
mainPresenter: MainPresenter | ||
): BasePresenter(mainPresenter), ITopBarPresenter { | ||
|
||
private val _uniqueAvatar = MutableStateFlow(userRepository.data.value?.uniqueAvatar) | ||
override val uniqueAvatar: StateFlow<PlatformImage?> get() = _uniqueAvatar | ||
|
||
private fun setUniqueAvatar(value: PlatformImage?) { | ||
_uniqueAvatar.value = value | ||
} | ||
|
||
init { | ||
refresh() | ||
} | ||
|
||
override fun onViewAttached() { | ||
super.onViewAttached() | ||
refresh() | ||
} | ||
|
||
private fun refresh() { | ||
backgroundScope.launch { | ||
userRepository.fetch().let { | ||
setUniqueAvatar(it?.uniqueAvatar) | ||
} | ||
} | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
...n/src/commonMain/kotlin/network/bisq/mobile/presentation/ui/uicases/TabContainerScreen.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
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
23 changes: 23 additions & 0 deletions
23
...rc/iosMain/kotlin/network/bisq/mobile/presentation/ui/components/atoms/icons/Icons.ios.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,23 @@ | ||
package network.bisq.mobile.presentation.ui.components.atoms.icons | ||
|
||
import androidx.compose.ui.graphics.painter.BitmapPainter | ||
import androidx.compose.ui.graphics.painter.Painter | ||
import androidx.compose.ui.graphics.toComposeImageBitmap | ||
import network.bisq.mobile.domain.PlatformImage | ||
import network.bisq.mobile.service.IosImageUtil.toByteArray | ||
import org.jetbrains.skia.Image | ||
import platform.UIKit.UIImage | ||
import platform.UIKit.UIImagePNGRepresentation | ||
|
||
actual fun rememberPlatformImagePainter(platformImage: PlatformImage): Painter { | ||
val uiImage = platformImage as UIImage | ||
val skiaImage = uiImage.toSkiaImage() | ||
return BitmapPainter(skiaImage.toComposeImageBitmap()) | ||
} | ||
|
||
// Helper function to convert UIImage to Skia Image | ||
fun UIImage.toSkiaImage(): Image { | ||
val nsData = UIImagePNGRepresentation(this)!! | ||
val byteArray = nsData.toByteArray() | ||
return Image.makeFromEncoded(byteArray) | ||
} |