-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate sample to Compose Navigation
- Loading branch information
1 parent
4d22b80
commit fce2b88
Showing
16 changed files
with
576 additions
and
586 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
5 changes: 2 additions & 3 deletions
5
sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/App.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,13 +1,12 @@ | ||
package com.mohamedrejeb.richeditor.sample.common | ||
|
||
import androidx.compose.runtime.* | ||
import cafe.adriel.voyager.navigator.Navigator | ||
import com.mohamedrejeb.richeditor.sample.common.home.HomeScreen | ||
import com.mohamedrejeb.richeditor.sample.common.navigation.NavGraph | ||
import com.mohamedrejeb.richeditor.sample.common.ui.theme.ComposeRichEditorTheme | ||
|
||
@Composable | ||
fun App() { | ||
ComposeRichEditorTheme { | ||
Navigator(HomeScreen) | ||
NavGraph() | ||
} | ||
} |
111 changes: 0 additions & 111 deletions
111
...ommon/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/home/HomeContent.kt
This file was deleted.
Oops, something went wrong.
95 changes: 90 additions & 5 deletions
95
...common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/home/HomeScreen.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,13 +1,98 @@ | ||
package com.mohamedrejeb.richeditor.sample.common.home | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material3.* | ||
import androidx.compose.runtime.Composable | ||
import cafe.adriel.voyager.core.screen.Screen | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import com.mohamedrejeb.richeditor.model.rememberRichTextState | ||
import com.mohamedrejeb.richeditor.ui.material3.RichText | ||
|
||
object HomeScreen: Screen { | ||
@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) | ||
@Composable | ||
fun HomeScreen( | ||
navigateToRichEditor: () -> Unit, | ||
navigateToHtmlEditor: () -> Unit, | ||
navigateToMarkdownEditor: () -> Unit, | ||
navigateToSlack: () -> Unit, | ||
) { | ||
val richTextState = rememberRichTextState() | ||
|
||
@Composable | ||
override fun Content() { | ||
HomeContent() | ||
LaunchedEffect(Unit) { | ||
richTextState.setHtml("<u>Welcome</u> to <b>Compose Rich Editor Demo</b>") | ||
} | ||
|
||
Scaffold( | ||
topBar = { | ||
TopAppBar( | ||
title = { Text("Compose Rich Editor") }, | ||
) | ||
}, | ||
modifier = Modifier | ||
.fillMaxSize() | ||
) { paddingValues -> | ||
LazyColumn( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
contentPadding = paddingValues, | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(paddingValues) | ||
.windowInsetsPadding(WindowInsets.ime) | ||
.padding(20.dp) | ||
) { | ||
item { | ||
Spacer(modifier = Modifier.height(20.dp)) | ||
} | ||
|
||
item { | ||
RichText( | ||
state = richTextState, | ||
style = MaterialTheme.typography.displaySmall, | ||
textAlign = TextAlign.Center, | ||
modifier = Modifier | ||
.padding(20.dp) | ||
) | ||
} | ||
|
||
item { | ||
Spacer(modifier = Modifier.height(20.dp)) | ||
} | ||
|
||
item { | ||
Button( | ||
onClick = navigateToRichEditor, | ||
) { | ||
Text("Rich Text Editor Demo") | ||
} | ||
} | ||
|
||
item { | ||
Button( | ||
onClick = navigateToHtmlEditor, | ||
) { | ||
Text("HTML Editor Demo") | ||
} | ||
} | ||
|
||
item { | ||
Button( | ||
onClick = navigateToMarkdownEditor, | ||
) { | ||
Text("Markdown Editor Demo") | ||
} | ||
} | ||
|
||
item { | ||
Button( | ||
onClick = navigateToSlack, | ||
) { | ||
Text("Slack Clone Demo") | ||
} | ||
} | ||
} | ||
} | ||
} |
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
13 changes: 0 additions & 13 deletions
13
...ommonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/htmleditor/HtmlEditorScreen.kt
This file was deleted.
Oops, something went wrong.
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
13 changes: 0 additions & 13 deletions
13
...n/kotlin/com/mohamedrejeb/richeditor/sample/common/markdowneditor/MarkdownEditorScreen.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.