-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #649 This introduces JS support to the core Circuit artifacts (via `nodejs()`) and also adds a browser app to the `counter` sample. Some things along the way - Adding an expect/actual indirection for the `TestEventSink` supertype to support JS as JS compilation doesn't allow implementation of function types. - Consolidating around recommending `Screen` object types be `data object` for better toString()-ability. We can't use `Screen::class.simpleName` in common code due to JS reflection limitations, so using this as an opportunity to lean into `data object` more since the lack of a toString() on objects was initially why we didn't do that. - Extract the Counter UI in the counter sample to `common`. Will eventually port Desktop to this too, but saving that for a later PR. - Moved `SwiftSupport` in counter sample to iOS source set. https://github.com/slackhq/circuit/assets/1361086/a47ef192-c70e-4958-a989-790c4010561f --------- Co-authored-by: Jake Wharton <[email protected]>
- Loading branch information
1 parent
cef9eb0
commit caef35a
Showing
48 changed files
with
3,137 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
**/snapshots/**/*.png filter=lfs diff=lfs merge=lfs -text | ||
**/generated/baselineProfiles/** linguist-generated=true | ||
**/yarn.lock linguist-generated=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
8 changes: 8 additions & 0 deletions
8
backstack/src/jsMain/kotlin/com/slack/circuit/backstack/BackStackRecordLocalProvider.js.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 com.slack.circuit.backstack | ||
|
||
import androidx.compose.runtime.ProvidableCompositionLocal | ||
import androidx.compose.runtime.compositionLocalOf | ||
|
||
internal actual val LocalBackStackRecordLocalProviders: | ||
ProvidableCompositionLocal<List<BackStackRecordLocalProvider<BackStack.Record>>> | ||
get() = compositionLocalOf { emptyList() } |
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
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
...it-foundation/src/jvmMain/kotlin/com/slack/circuit/foundation/internal/BackHandler.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,10 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.foundation.internal | ||
|
||
import androidx.compose.runtime.Composable | ||
|
||
@Composable | ||
public actual fun BackHandler(enabled: Boolean, onBack: () -> Unit) { | ||
// No-op | ||
} |
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
12 changes: 12 additions & 0 deletions
12
circuit-retained/src/jsMain/kotlin/com/slack/circuit/retained/CanRetainChecker.js.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,12 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.retained | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
|
||
/** Checks whether or not we can retain in the current composable context. */ | ||
@Composable | ||
internal actual fun rememberCanRetainChecker(): () -> Boolean { | ||
return remember { { false } } | ||
} |
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
7 changes: 7 additions & 0 deletions
7
circuit-runtime/src/jsMain/kotlin/com/slack/circuit/runtime/Screen.js.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,7 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.runtime | ||
|
||
import androidx.compose.runtime.Immutable | ||
|
||
@Immutable public actual interface Screen |
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
5 changes: 5 additions & 0 deletions
5
circuit-test/src/androidMain/kotlin/com/slack/circuit/test/TestEventSink.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,5 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.test | ||
|
||
public actual sealed interface BaseTestEventSinkType<UiEvent> : (UiEvent) -> Unit |
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
5 changes: 5 additions & 0 deletions
5
circuit-test/src/iosMain/kotlin/com/slack/circuit/test/TestEventSink.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,5 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.test | ||
|
||
public actual sealed interface BaseTestEventSinkType<UiEvent> : (UiEvent) -> Unit |
17 changes: 17 additions & 0 deletions
17
circuit-test/src/jsMain/kotlin/com/slack/circuit/test/TestEventSink.js.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,17 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.test | ||
|
||
import com.slack.circuit.runtime.CircuitUiEvent | ||
|
||
public actual sealed interface BaseTestEventSinkType<UiEvent> { | ||
public actual operator fun invoke(event: UiEvent) | ||
} | ||
|
||
/** | ||
* A helper function for creating a function wrapper around this [TestEventSink] for use in tests as | ||
* an event sink function. We have to do this workaround in JS due to Kotlin/JS not allowing | ||
* function type extension directly. | ||
*/ | ||
public fun <UiEvent : CircuitUiEvent> TestEventSink<UiEvent>.asEventSinkFunction(): | ||
(UiEvent) -> Unit = this::invoke |
5 changes: 5 additions & 0 deletions
5
circuit-test/src/jvmMain/kotlin/com/slack/circuit/test/TestEventSink.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 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuit.test | ||
|
||
public actual sealed interface BaseTestEventSinkType<UiEvent> : (UiEvent) -> Unit |
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
10 changes: 10 additions & 0 deletions
10
circuitx/overlays/src/jsMain/kotlin/com/slack/circuitx/overlays/FullScreenOverlay.js.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,10 @@ | ||
// Copyright (C) 2023 Slack Technologies, LLC | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package com.slack.circuitx.overlays | ||
|
||
import com.slack.circuit.overlay.OverlayHost | ||
import com.slack.circuit.runtime.Screen | ||
|
||
public actual suspend fun OverlayHost.showFullScreenOverlay(screen: Screen) { | ||
show(FullScreenOverlay(screen)) | ||
} |
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
Oops, something went wrong.