File tree Expand file tree Collapse file tree 11 files changed +85
-15
lines changed
compose-multiplatform-common/src
commonMain/kotlin/com/huanshankeji/compose
jsMain/kotlin/com/huanshankeji/compose
jvmMain/kotlin/com/huanshankeji/compose
compose-multiplatform-material/src
commonMain/kotlin/com/huanshankeji/compose/material
jsMain/kotlin/com/huanshankeji/compose/material
jvmMain/kotlin/com/huanshankeji/compose/material
demo/src/commonMain/kotlin/com/huanshankeji/compose/material/demo Expand file tree Collapse file tree 11 files changed +85
-15
lines changed Original file line number Diff line number Diff line change 11package com.huanshankeji.compose
22
33import androidx.compose.runtime.Composable
4+ import com.huanshankeji.compose.ui.Element
5+ import com.huanshankeji.compose.ui.ModifierOrAttrs
6+
7+ expect abstract class BasicTextElement : Element
48
59@Composable
6- expect fun BasicText (text : String )
10+ expect fun BasicText (text : String , modifierOrAttrs : ModifierOrAttrs < BasicTextElement > = null )
Original file line number Diff line number Diff line change 1+ package com.huanshankeji.compose
2+
3+ import androidx.compose.runtime.Composable
4+
5+ /* * A raw text composable which doesn't add any element on web. */
6+ @Composable
7+ expect fun RawText (text : String )
Original file line number Diff line number Diff line change 11package com.huanshankeji.compose
22
33import androidx.compose.runtime.Composable
4+ import com.huanshankeji.compose.ui.ModifierOrAttrs
5+ import com.huanshankeji.compose.ui.toAttrs
6+ import org.jetbrains.compose.web.dom.Span
47import org.jetbrains.compose.web.dom.Text
8+ import org.w3c.dom.HTMLSpanElement
9+
10+ actual typealias BasicTextElement = HTMLSpanElement
511
612@Composable
7- actual fun BasicText (text : String ) =
8- Text (text)
13+ actual fun BasicText (text : String , modifierOrAttrs : ModifierOrAttrs < HTMLSpanElement > ) =
14+ Span (modifierOrAttrs.toAttrs()) { Text (text) }
Original file line number Diff line number Diff line change 1+ package com.huanshankeji.compose
2+
3+ import androidx.compose.runtime.Composable
4+ import org.jetbrains.compose.web.dom.Text
5+
6+ @Composable
7+ actual fun RawText (text : String ) =
8+ Text (text)
Original file line number Diff line number Diff line change 11package com.huanshankeji.compose
22
33import androidx.compose.runtime.Composable
4+ import com.huanshankeji.compose.ui.Element
5+ import com.huanshankeji.compose.ui.ModifierOrAttrs
6+ import com.huanshankeji.compose.ui.toModifier
7+
8+ actual abstract class BasicTextElement : Element ()
49
510@Composable
6- actual fun BasicText (text : String ) =
7- androidx.compose.foundation.text.BasicText (text)
11+ actual fun BasicText (text : String , modifierOrAttrs : ModifierOrAttrs < BasicTextElement > ) =
12+ androidx.compose.foundation.text.BasicText (text, modifierOrAttrs.toModifier() )
Original file line number Diff line number Diff line change 1+ package com.huanshankeji.compose
2+
3+ import androidx.compose.runtime.Composable
4+
5+ @Composable
6+ actual fun RawText (text : String ) =
7+ androidx.compose.foundation.text.BasicText (text)
Original file line number Diff line number Diff line change 11package com.huanshankeji.compose.material
22
33import androidx.compose.runtime.Composable
4+ import com.huanshankeji.compose.ui.Element
5+ import com.huanshankeji.compose.ui.ModifierOrAttrs
46
7+ expect abstract class TextElement : Element
8+
9+ @RequiresOptIn(
10+ " The `com.huanshankeji.compose.material.Text` function " +
11+ " can be easily confused with other Composable functions named `Text` " +
12+ " such as `androidx.compose.material.Text` and `org.jetbrains.compose.web.dom.Text` " +
13+ " if not careful. " +
14+ " Opt-in to use this API or use `MaterialText` instead." ,
15+ RequiresOptIn .Level .WARNING
16+ )
17+ @Retention(AnnotationRetention .BINARY )
18+ @Target(AnnotationTarget .CLASS , AnnotationTarget .FUNCTION )
19+ annotation class ConfusableTextApi
20+
21+ @ConfusableTextApi
22+ @Composable
23+ expect fun Text (text : String , modifierOrAttrs : ModifierOrAttrs <TextElement > = null)
24+
25+ @Suppress(" NOTHING_TO_INLINE" )
26+ @OptIn(ConfusableTextApi ::class )
527@Composable
6- expect fun Text (text : String )
28+ inline fun MaterialText (text : String , noinline modifierOrAttrs : ModifierOrAttrs <TextElement > = null) =
29+ Text (text, modifierOrAttrs)
Original file line number Diff line number Diff line change @@ -2,7 +2,11 @@ package com.huanshankeji.compose.material
22
33import androidx.compose.runtime.Composable
44import com.huanshankeji.compose.BasicText
5+ import com.huanshankeji.compose.ui.ModifierOrAttrs
6+ import org.w3c.dom.HTMLSpanElement
7+
8+ actual typealias TextElement = HTMLSpanElement
59
610@Composable
7- actual fun Text (text : String ) =
8- BasicText (text)
11+ actual fun Text (text : String , modifierOrAttrs : ModifierOrAttrs < TextElement > ) =
12+ BasicText (text, modifierOrAttrs )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ package com.huanshankeji.compose.material
2+
3+ import androidx.compose.runtime.Composable
4+ import com.huanshankeji.compose.ui.Element
5+ import com.huanshankeji.compose.ui.ModifierOrAttrs
6+ import com.huanshankeji.compose.ui.toModifier
7+
8+ actual abstract class TextElement : Element ()
9+
10+ @Composable
11+ actual fun Text (text : String , modifierOrAttrs : ModifierOrAttrs <TextElement >) =
12+ androidx.compose.material.Text (text, modifierOrAttrs.toModifier())
You can’t perform that action at this time.
0 commit comments