-
Notifications
You must be signed in to change notification settings - Fork 202
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
308558a
commit 2abcee2
Showing
18 changed files
with
200 additions
and
6 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
8 changes: 8 additions & 0 deletions
8
...lin/org/mobilenativefoundation/sample/octonaut/xplat/feat/RealNotificationsTab.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,8 @@ | ||
package org.mobilenativefoundation.sample.octonaut.xplat.feat | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
import org.mobilenativefoundation.sample.octonaut.xplat.feat.notificationsTab.api.NotificationsTab | ||
|
||
@Parcelize | ||
actual object RealNotificationsTab : NotificationsTab, Parcelable |
33 changes: 33 additions & 0 deletions
33
...kotlin/org/mobilenativefoundation/sample/octonaut/xplat/feat/NotificationsTabPresenter.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,33 @@ | ||
package org.mobilenativefoundation.sample.octonaut.xplat.feat | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.collectAsState | ||
import me.tatarka.inject.annotations.Inject | ||
import org.mobilenativefoundation.sample.octonaut.xplat.feat.notificationsTab.api.NotificationsTab | ||
|
||
@Inject | ||
class NotificationsTabPresenter(private val warehouse: NotificationsTabWarehouse) : NotificationsTab.Presenter { | ||
private fun on(event: NotificationsTab.Event) { | ||
when (event) { | ||
is NotificationsTab.Event.MarkDone -> warehouse.dispatch( | ||
NotificationsTabWarehouseAction.MarkDone( | ||
event.notificationId | ||
) | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
override fun present(): NotificationsTab.State { | ||
val warehouseState = warehouse.state.collectAsState() | ||
|
||
return warehouseState.value.notifications.let { | ||
if (it.isEmpty()) { | ||
NotificationsTab.State.Loading | ||
} else { | ||
NotificationsTab.State.Loaded(it, ::on) | ||
} | ||
} | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...onMain/kotlin/org/mobilenativefoundation/sample/octonaut/xplat/feat/NotificationsTabUi.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,30 @@ | ||
package org.mobilenativefoundation.sample.octonaut.xplat.feat | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import me.tatarka.inject.annotations.Inject | ||
import org.mobilenativefoundation.sample.octonaut.xplat.feat.notificationsTab.api.NotificationsTab | ||
|
||
@Inject | ||
class NotificationsTabUi : NotificationsTab.Ui { | ||
@Composable | ||
override fun Content(state: NotificationsTab.State, modifier: Modifier) { | ||
Column { | ||
when (state) { | ||
NotificationsTab.State.Initial -> Text("Initial") | ||
is NotificationsTab.State.Loaded -> LoadedContent(state) | ||
is NotificationsTab.State.Loading -> Text("Loading") | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun LoadedContent(state: NotificationsTab.State.Loaded) { | ||
|
||
state.notifications.forEach { | ||
Text(it.url) | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...kotlin/org/mobilenativefoundation/sample/octonaut/xplat/feat/NotificationsTabWarehouse.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,16 @@ | ||
package org.mobilenativefoundation.sample.octonaut.xplat.feat | ||
|
||
import org.mobilenativefoundation.market.warehouse.Warehouse | ||
import org.mobilenativefoundation.sample.octonaut.xplat.domain.notifications.api.Notification | ||
|
||
data class NotificationsTabWarehouseState( | ||
val notifications: List<Notification> | ||
) : Warehouse.State | ||
|
||
sealed interface NotificationsTabWarehouseAction : Warehouse.Action { | ||
data class MarkDone( | ||
val notificationId: String | ||
) : NotificationsTabWarehouseAction | ||
} | ||
|
||
typealias NotificationsTabWarehouse = Warehouse<NotificationsTabWarehouseState, NotificationsTabWarehouseAction> |
28 changes: 28 additions & 0 deletions
28
...org/mobilenativefoundation/sample/octonaut/xplat/feat/NotificationsTabWarehouseFactory.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,28 @@ | ||
package org.mobilenativefoundation.sample.octonaut.xplat.feat | ||
|
||
import me.tatarka.inject.annotations.Inject | ||
import org.mobilenativefoundation.sample.octonaut.xplat.common.market.WarehouseBuilderFactory | ||
import org.mobilenativefoundation.sample.octonaut.xplat.domain.notifications.api.NotificationsSupplier | ||
|
||
@Inject | ||
class NotificationsTabWarehouseFactory( | ||
private val notificationsSupplier: NotificationsSupplier, | ||
private val warehouseBuilderFactory: WarehouseBuilderFactory | ||
) { | ||
fun create(): NotificationsTabWarehouse { | ||
val warehouseBuilder = | ||
warehouseBuilderFactory.create<NotificationsTabWarehouseState, NotificationsTabWarehouseAction>() | ||
|
||
return warehouseBuilder.extractor { marketState -> | ||
NotificationsTabWarehouseState(marketState.notifications) | ||
} | ||
.actionHandler { action, marketState -> | ||
when (action) { | ||
is NotificationsTabWarehouseAction.MarkDone -> { | ||
// TODO | ||
} | ||
} | ||
} | ||
.build() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...Main/kotlin/org/mobilenativefoundation/sample/octonaut/xplat/feat/RealNotificationsTab.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,5 @@ | ||
package org.mobilenativefoundation.sample.octonaut.xplat.feat | ||
|
||
import org.mobilenativefoundation.sample.octonaut.xplat.feat.notificationsTab.api.NotificationsTab | ||
|
||
expect object RealNotificationsTab : NotificationsTab |
5 changes: 5 additions & 0 deletions
5
.../kotlin/org/mobilenativefoundation/sample/octonaut/xplat/feat/RealNotificationsTab.jvm.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,5 @@ | ||
package org.mobilenativefoundation.sample.octonaut.xplat.feat | ||
|
||
import org.mobilenativefoundation.sample.octonaut.xplat.feat.notificationsTab.api.NotificationsTab | ||
|
||
actual object RealNotificationsTab : NotificationsTab |
5 changes: 5 additions & 0 deletions
5
...tlin/org/mobilenativefoundation/sample/octonaut/xplat/feat/RealNotificationsTab.native.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,5 @@ | ||
package org.mobilenativefoundation.sample.octonaut.xplat.feat | ||
|
||
import org.mobilenativefoundation.sample.octonaut.xplat.feat.notificationsTab.api.NotificationsTab | ||
|
||
actual object RealNotificationsTab : NotificationsTab |