From 95967174ab98e3609a6842d2f3ece0fcf7aeae3e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 20:58:13 +0000 Subject: [PATCH] Deploy to GitHub pages --- 404.html | 33 +++ arch/index.html | 172 ++++++++++++++++ assets/404.html-46166703.js | 1 + assets/404.html-479d21d1.js | 1 + assets/app-1ab0947c.js | 6 + assets/apps-09410819.png | Bin 0 -> 482988 bytes assets/avatar-0004435a.png | Bin 0 -> 27312 bytes assets/back-to-top-8efcbe56.svg | 1 + assets/data_layer-bd8ec81c.png | Bin 0 -> 42596 bytes assets/diagramme_sql-35788f98.png | Bin 0 -> 28583 bytes assets/framework-96b046e1.js | 5 + assets/hello_desktop-d4580e30.png | Bin 0 -> 51498 bytes assets/index.html-0ad677ee.js | 110 ++++++++++ assets/index.html-222eb96a.js | 1 + assets/index.html-26328a0f.js | 1 + assets/index.html-29394223.js | 215 +++++++++++++++++++ assets/index.html-45284dbd.js | 263 +++++++++++++++++++++++ assets/index.html-5743b942.js | 34 +++ assets/index.html-5ecb171b.js | 14 ++ assets/index.html-5fa08e98.js | 1 + assets/index.html-68bf2106.js | 198 ++++++++++++++++++ assets/index.html-6dfb7521.js | 1 + assets/index.html-896ec92f.js | 140 +++++++++++++ assets/index.html-a66c6530.js | 1 + assets/index.html-a72fc4f0.js | 1 + assets/index.html-aea5f905.js | 115 +++++++++++ assets/index.html-b1007bda.js | 1 + assets/index.html-b24acf8a.js | 1 + assets/index.html-b9a374bc.js | 1 + assets/index.html-c33e88ed.js | 277 +++++++++++++++++++++++++ assets/index.html-d4419357.js | 1 + assets/index.html-e976e08b.js | 1 + assets/kmp_sample_src-acaf2c10.png | Bin 0 -> 351661 bytes assets/logo_worldline-09e30c15.png | Bin 0 -> 14866 bytes assets/overview2-814ab937.png | Bin 0 -> 3593951 bytes assets/plugins_install-e22508b0.png | Bin 0 -> 31234 bytes assets/project_struct-029fcd16.png | Bin 0 -> 152943 bytes assets/quizscreen-b8a22bd8.png | Bin 0 -> 51746 bytes assets/routes-9ce9907e.png | Bin 0 -> 16033 bytes assets/run-f7fe01b1.png | Bin 0 -> 119679 bytes assets/scorescreen-ba03b337.png | Bin 0 -> 24003 bytes assets/screens-1d6b8878.png | Bin 0 -> 358419 bytes assets/server_tree-b9c27a47.png | Bin 0 -> 46969 bytes assets/style-a09f3c99.css | 1 + assets/template-efdbf316.png | Bin 0 -> 94502 bytes assets/toolbox-5b7f0650.png | Bin 0 -> 198013 bytes assets/uml-233ee0d0.png | Bin 0 -> 14675 bytes assets/welcomescreen-1c915162.png | Bin 0 -> 28193 bytes configure/index.html | 230 +++++++++++++++++++++ database/index.html | 247 ++++++++++++++++++++++ favicon.ico | Bin 0 -> 89808 bytes icon-192x192.png | Bin 0 -> 28392 bytes icon-256x256.png | Bin 0 -> 44303 bytes icon-384x384.png | Bin 0 -> 102218 bytes icon-512x512.png | Bin 0 -> 93315 bytes index.html | 33 +++ kotlin_logo.svg | 6 + logo.png | Bin 0 -> 88422 bytes logo_worldline.png | Bin 0 -> 14866 bytes manifest.webmanifest | 31 +++ nav/index.html | 142 +++++++++++++ network/index.html | 309 ++++++++++++++++++++++++++++ overview/index.html | 46 +++++ preferences/index.html | 147 +++++++++++++ res/index.html | 66 ++++++ robots.txt | 3 + ui/index.html | 295 ++++++++++++++++++++++++++ 67 files changed, 3152 insertions(+) create mode 100644 404.html create mode 100644 arch/index.html create mode 100644 assets/404.html-46166703.js create mode 100644 assets/404.html-479d21d1.js create mode 100644 assets/app-1ab0947c.js create mode 100644 assets/apps-09410819.png create mode 100644 assets/avatar-0004435a.png create mode 100644 assets/back-to-top-8efcbe56.svg create mode 100644 assets/data_layer-bd8ec81c.png create mode 100644 assets/diagramme_sql-35788f98.png create mode 100644 assets/framework-96b046e1.js create mode 100644 assets/hello_desktop-d4580e30.png create mode 100644 assets/index.html-0ad677ee.js create mode 100644 assets/index.html-222eb96a.js create mode 100644 assets/index.html-26328a0f.js create mode 100644 assets/index.html-29394223.js create mode 100644 assets/index.html-45284dbd.js create mode 100644 assets/index.html-5743b942.js create mode 100644 assets/index.html-5ecb171b.js create mode 100644 assets/index.html-5fa08e98.js create mode 100644 assets/index.html-68bf2106.js create mode 100644 assets/index.html-6dfb7521.js create mode 100644 assets/index.html-896ec92f.js create mode 100644 assets/index.html-a66c6530.js create mode 100644 assets/index.html-a72fc4f0.js create mode 100644 assets/index.html-aea5f905.js create mode 100644 assets/index.html-b1007bda.js create mode 100644 assets/index.html-b24acf8a.js create mode 100644 assets/index.html-b9a374bc.js create mode 100644 assets/index.html-c33e88ed.js create mode 100644 assets/index.html-d4419357.js create mode 100644 assets/index.html-e976e08b.js create mode 100644 assets/kmp_sample_src-acaf2c10.png create mode 100644 assets/logo_worldline-09e30c15.png create mode 100644 assets/overview2-814ab937.png create mode 100644 assets/plugins_install-e22508b0.png create mode 100644 assets/project_struct-029fcd16.png create mode 100644 assets/quizscreen-b8a22bd8.png create mode 100644 assets/routes-9ce9907e.png create mode 100644 assets/run-f7fe01b1.png create mode 100644 assets/scorescreen-ba03b337.png create mode 100644 assets/screens-1d6b8878.png create mode 100644 assets/server_tree-b9c27a47.png create mode 100644 assets/style-a09f3c99.css create mode 100644 assets/template-efdbf316.png create mode 100644 assets/toolbox-5b7f0650.png create mode 100644 assets/uml-233ee0d0.png create mode 100644 assets/welcomescreen-1c915162.png create mode 100644 configure/index.html create mode 100644 database/index.html create mode 100644 favicon.ico create mode 100644 icon-192x192.png create mode 100644 icon-256x256.png create mode 100644 icon-384x384.png create mode 100644 icon-512x512.png create mode 100644 index.html create mode 100644 kotlin_logo.svg create mode 100644 logo.png create mode 100644 logo_worldline.png create mode 100644 manifest.webmanifest create mode 100644 nav/index.html create mode 100644 network/index.html create mode 100644 overview/index.html create mode 100644 preferences/index.html create mode 100644 res/index.html create mode 100644 robots.txt create mode 100644 ui/index.html diff --git a/404.html b/404.html new file mode 100644 index 0000000..f6af0d2 --- /dev/null +++ b/404.html @@ -0,0 +1,33 @@ + + +
+ + + + + +Let's connect our Quiz app to internet.
Architecture basics
Everything You NEED to Know About MVVM Architecture Patterns
Data layer in KMP is under building but largly inspired by Android Architecture pattern
Repository classes are responsible for the following tasks:
"A flow is an asynchronous data stream that sequentially emits values and completes normally or with an exception."
There are multiple types of flow, for the Hands-on Lab, we will focus on StateFlow
A state flow is a hot flow because its active instance exists independently of the presence of collectors (our composables that consume the data)
"A coroutine is an instance of suspendable computation. It is conceptually similar to a thread, in the sense that it takes a block of code to run that works concurrently with the rest of the code. However, a coroutine is not bound to any particular thread. It may suspend its execution in one thread and resume in another one."
Add coroutine dependancy to your project.
commonMain.dependencies {
+ ...
+ implementation(libs.kotlinx.coroutines.core)
+ }
+
package com.worldline.quiz.data.datasources
+
+class MockDataSource {
+
+ fun generateDummyQuestionsList():List<Question>{
+ return listOf(
+ Question(
+ 1,
+ "Android is a great platform ?",
+ 1,
+ listOf(
+ Answer( 1,"YES"),
+ Answer(2,"NO")
+ )
+ ),
+ Question(
+ 1,
+ "Android is a bad platform ?",
+ 2,
+ listOf(
+ Answer( 1,"YES"),
+ Answer(2,"NO")
+ )
+ )
+ )
+ }
+
+}
+
package com.worldline.quiz.data
+
+class QuizRepository() {
+
+ private val mockDataSource = MockDataSource()
+ private val coroutineScope = CoroutineScope(Dispatchers.Main)
+ private var _questionState= MutableStateFlow(listOf<Question>())
+ var questionState = _questionState
+
+ init {
+ updateQuiz()
+ }
+
+ private fun updateQuiz(){
+ coroutineScope.launch {
+ _questionState.update {
+ mockDataSource.generateDummyQuestionsList()
+ }
+ }
+ }
+}
+
@Composable
+fun App(
+ navController: NavHostController = rememberNavController(),
+ quizRepository: QuizRepository = QuizRepository()
+) {
+
+ MaterialTheme {
+ NavHost(
+ navController = navController,
+ startDestination = "/welcome",
+ ) {
+
+
+ composable(route = "/welcome") {
+ welcomeScreen(
+ onStartButtonPushed = {
+ navController.navigate(route = "/quiz")
+ }
+ )
+ }
+ composable(route = "/quiz") {
+ val questions by quizRepository.questionState.collectAsState()
+ questionScreen(
+ questions = questions,
+ /* FOR SPEAKER TALK DEMO ON WEB APP */
+ onFinishButtonPushed = {
+ score: Int, questionSize: Int -> navController.navigate(route = "/score/$score/$questionSize")
+ }
+ )
+ }
+ composable(route = "/score/{score}/{total}") {
+ scoreScreen(
+ score = it.arguments?.getString("score")?.toInt() ?:-1,
+ total = it.arguments?.getString("total")?.toInt() ?:-1,
+ onResetButtonPushed = {
+ navController.navigate(route = "/quiz")
+ }
+ )
+ }
+
+ }
+ }
+}
+
Sources
The full solution for this section is availabe here
Third party Architecture libraries
Domain layer framework such as ViewModels
are just available on KMP. But you can also use a third party library such as Moko-MVVM
or KMM-ViewModel
or precompose
...
+ commonMain.dependencies {
+ ...
+ implementation(libs.androidx.lifecycle.viewmodel.compose)
+...
+
package com.worldline.quiz
+
+class QuizViewModel : ViewModel() {
+ private var quizRepository: QuizRepository = QuizRepository()
+ private var _questionState = MutableStateFlow(listOf<Question>())
+ var questionState: StateFlow<List<Question>> = _questionState
+
+ /* Can be replaced with explicit backing fields
+ val questionState : StateFlow<List<Question>>
+ field = MutableStateFlow(listOf<Question>())
+ -> in build.gradle.kts : sourceSets.all { languageSettings.enableLanguageFeature("ExplicitBackingFields") }
+ */
+
+ init {
+ getQuestionQuiz()
+ }
+
+ private fun getQuestionQuiz() {
+ viewModelScope.launch(Dispatchers.Default) {
+ _questionState.update {
+ quizRepository.updateQuiz()
+ }
+ }
+ }
+}
+
class QuizRepository {
+ private val mockDataSource = MockDataSource()
+ fun updateQuiz():List<Question>{
+ return mockDataSource.generateDummyQuestionsList()
+ }
+}
+
fun App(
+ navController: NavHostController = rememberNavController(),
+ quizViewModel: QuizViewModel = QuizViewModel()
+) {
+...
+composable(route = "/quiz") {
+ val questions by quizViewModel.questionState.collectAsState()
+
Sources
The full solution for this section is availabe here
โ If everything is fine, go to the next chapter โ
+2!#49i8yROldP4{R>}PiOYJrQ
zmao`fEBBMm#1*)}1SMinV0l_c5HR=k2 8^$z@PPwJHeFEQ%$f%Ty>pq4lIa@{#b=
zb%^xfV-5eIkFP#ltQ(2RMqdo)&OHofniO8MvTYQqo-
zAjR)MQuzzwPDNu{ZdUC0jhH~BrIoQ~S&9R~5D7kCmD@J+V|9XR;DPg1tEyOM`bbg{
zn7NdoHU6h8YlDV-x1Fu5jIud==?a6Y%UYKiHql6ln*wM`nM1hKBXeX8u&Gj-<0B?U
zk(BEL
aKbbxfOA_LxSgMxkrY
zqWd9fu2xTu2L&*(bOOuPKq00fnBC`AC__O4-p#lnw|v#O>Ryr*%|ooa2%=x@+F;o6
zgI)xKlF+u}Gjpw)!gpIH@W7_AxiZ1`N&TScRPb-Mgdxg)`uF)bmIe$kZ!6I+(=T~E
zCwv8y;$S=~ZJ1Zs4Cj0(
zbxYnPB^7Rrd=`e^h8+SC
$HkZGFce}
zu6xwo2B4acHF`f@0>0rc(<+rD$DnW54FL|Sjb2jl62)G>T?7qSj*9BBk6F_uT@M2h
zT54`5pqifgY(JK?WTY>Zs)Wc
ICIRRZ69{#O@o>Gf!pPlL+bCWfep2Ie-zA
zJ_j^w4m1LtA3!a`PTFmDhO#=LHY+7l&QBUUuLmRC_P-cuJhYCeF-%fn4$#7;@Yp`V
z));a3YdX5#Ytu{^?~EX26fZ|2o6lwNU8+aE6r0DR$rqIfy8OF39G2^H`h(t@2>8klpVG}U#nT=5GH@onE=+7+ImO!_0-UKGrgRW=W;5}*3`
z=0Q>ke<`NDWjc^+1gs2{`05&6I8Q`KuS5>P$_)eDI