├── docs
├── images
│ ├── Main.png
│ ├── main.png
│ ├── detail1.png
│ └── detail2.png
├── index.html
└── KmdcTest.js.LICENSE.txt
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── src
├── jsMain
│ ├── kotlin
│ │ └── de.jensklingenberg.mealapp
│ │ │ ├── Main.kt
│ │ │ ├── Page.kt
│ │ │ ├── common
│ │ │ ├── Drawer.kt
│ │ │ ├── AppBar.kt
│ │ │ └── Components.kt
│ │ │ ├── detail
│ │ │ ├── DetailViewModel.kt
│ │ │ └── DetailPage.kt
│ │ │ ├── mainpage
│ │ │ ├── MealCard.kt
│ │ │ ├── InfoDialog.kt
│ │ │ ├── Filter.kt
│ │ │ ├── Search.kt
│ │ │ ├── MainPage.kt
│ │ │ └── MainPageViewModel.kt
│ │ │ └── App.kt
│ └── resources
│ │ └── index.html
└── commonMain
│ └── kotlin
│ └── de.jensklingenberg.mealapp
│ ├── MealDataSource.kt
│ ├── network
│ └── model
│ │ └── Meal.kt
│ ├── mealdbapi
│ ├── MealApiService.kt
│ └── MealResult.kt
│ └── MealRepository.kt
├── .idea
├── vcs.xml
├── .gitignore
├── artifacts
│ └── KmdcTest_js.xml
├── misc.xml
└── gradle.xml
├── gradle.properties
├── webpack.config.d
└── sass.js
├── .gitignore
├── settings.gradle.kts
├── README.md
├── gradlew.bat
├── gradlew
└── License.md
/docs/images/Main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KmdcExample/master/docs/images/Main.png
--------------------------------------------------------------------------------
/docs/images/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KmdcExample/master/docs/images/main.png
--------------------------------------------------------------------------------
/docs/images/detail1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KmdcExample/master/docs/images/detail1.png
--------------------------------------------------------------------------------
/docs/images/detail2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KmdcExample/master/docs/images/detail2.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Foso/KmdcExample/master/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/Main.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp
2 |
3 |
4 | fun main() {
5 | App()
6 | }
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/Page.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp
2 |
3 | sealed class Page {
4 | object Main : Page()
5 | class Detail(val mealId: Int) : Page()
6 | }
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | kotlin.code.style=official
2 | kotlin.native.enableDependencyPropagation=false
3 | kotlin.js.webpack.major.version=5
4 | kotlin.version=1.7.0
5 | agp.version=4.2.2
6 | compose.version=1.2.0-alpha01-dev745
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/.idea/artifacts/KmdcTest_js.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/build/libs
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Sample
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/jsMain/resources/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Sample
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/webpack.config.d/sass.js:
--------------------------------------------------------------------------------
1 | config.module.rules.push({
2 | test: /\.(scss|sass)$/,
3 | use: [
4 | /**
5 | * fallback to style-loader in development
6 | * "style-loader" creates style nodes from JS strings
7 | */
8 | "style-loader", // translates CSS into CommonJS
9 | "css-loader", // translates CSS into CommonJS
10 | "sass-loader" // compiles Sass to CSS, using Node Sass by default
11 | ]
12 | });
13 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/commonMain/kotlin/de.jensklingenberg.mealapp/MealDataSource.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp
2 |
3 | import de.jensklingenberg.mealapp.network.model.Meal
4 | import de.jensklingenberg.mealdbapi.Category
5 |
6 | interface MealDataSource {
7 | suspend fun getMeals(): List
8 | fun getIngredientImageUrl(name: String): String
9 | suspend fun getCategories(): List
10 | suspend fun getMealsByCategory(categoryName: String): List
11 | suspend fun getMealsByName(categoryName: String): List
12 | suspend fun getMealsById(categoryName: Int): Meal?
13 | }
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
16 |
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | build/
3 | !gradle/wrapper/gradle-wrapper.jar
4 | !**/src/main/**/build/
5 | !**/src/test/**/build/
6 |
7 | ### IntelliJ IDEA ###
8 | .idea/modules.xml
9 | .idea/jarRepositories.xml
10 | .idea/compiler.xml
11 | .idea/libraries/
12 | *.iws
13 | *.iml
14 | *.ipr
15 | out/
16 | !**/src/main/**/out/
17 | !**/src/test/**/out/
18 |
19 | ### Eclipse ###
20 | .apt_generated
21 | .classpath
22 | .factorypath
23 | .project
24 | .settings
25 | .springBeans
26 | .sts4-cache
27 | bin/
28 | !**/src/main/**/bin/
29 | !**/src/test/**/bin/
30 |
31 | ### NetBeans ###
32 | /nbproject/private/
33 | /nbbuild/
34 | /dist/
35 | /nbdist/
36 | /.nb-gradle/
37 |
38 | ### VS Code ###
39 | .vscode/
40 |
41 | ### Mac OS ###
42 | .DS_Store
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | // Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
2 |
3 |
4 |
5 | pluginManagement {
6 | repositories {
7 | google()
8 | gradlePluginPortal()
9 | mavenCentral()
10 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
11 |
12 |
13 | }
14 |
15 | plugins {
16 | kotlin("multiplatform").version(extra["kotlin.version"] as String)
17 | id("org.jetbrains.compose").version(extra["compose.version"] as String)
18 | }
19 | }
20 |
21 | rootProject.name = "KmdcTest"
22 |
23 | buildscript {
24 | repositories {
25 | gradlePluginPortal()
26 | google()
27 | mavenCentral()
28 | }
29 | dependencies {
30 |
31 | classpath("org.jetbrains.kotlin:kotlin-serialization:1.7.0")
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/common/Drawer.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.common
2 |
3 | import androidx.compose.runtime.Composable
4 | import dev.petuska.kmdc.drawer.*
5 | import dev.petuska.kmdc.typography.MDCBody1
6 | import org.jetbrains.compose.web.dom.Text
7 |
8 | @Composable
9 | fun Drawer(drawerOpened: Boolean) {
10 | var drawerOpened1 = drawerOpened
11 | MDCDrawer(open = drawerOpened1, type = MDCDrawerType.Modal, attrs = {
12 |
13 | onOpened { drawerOpened1 = true }
14 | onClosed { drawerOpened1 = false }
15 | style {
16 | property("height", "fit-content")
17 | }
18 |
19 | }) {
20 |
21 | Content {
22 | Text("de.jensklingenberg.mealapp.common.Drawer")
23 | }
24 | MDCDrawerAppContent {
25 | MDCBody1("de.jensklingenberg.mealapp.App Content")
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # KmdcExample
2 | Example project with Compose HTML and [Kmdc](https://github.com/mpetuska/kmdc) https://foso.github.io/KmdcExample/
3 |
4 |
5 | | MainPage | Detail1 |
6 | | ------------------ |----------------------------------------------------------------------------------------------------------------------|
7 | |
|
|
8 |
9 | | Detail2 |
10 | | ------------------ |
11 | |
|
12 |
--------------------------------------------------------------------------------
/src/commonMain/kotlin/de.jensklingenberg.mealapp/network/model/Meal.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.network.model
2 |
3 | import de.jensklingenberg.mealdbapi.ApiMeal
4 | import de.jensklingenberg.mealdbapi.Ingredient
5 | import de.jensklingenberg.mealdbapi.getIngredients
6 | import de.jensklingenberg.mealdbapi.tags
7 |
8 | data class Meal(
9 | var strMeal: String,
10 | var idMeal: Int,
11 | var strMealThumb: String,
12 | val ingredients: List,
13 | var strTags: List = emptyList(),
14 | var strCategory: String = "",
15 | var strInstructions: String = "",
16 | var strArea: String? = "",
17 | )
18 |
19 | fun ApiMeal.mapToMeal(): Meal {
20 | val ingredients = this.getIngredients()
21 | val tags = this.tags()
22 | return Meal(
23 | strMeal = strMeal,
24 | ingredients = ingredients,
25 | idMeal = idMeal,
26 | strMealThumb = strMealThumb,
27 | strTags = tags,
28 | strInstructions = strInstructions,
29 | strArea = strArea
30 | )
31 | }
--------------------------------------------------------------------------------
/src/commonMain/kotlin/de.jensklingenberg.mealapp/mealdbapi/MealApiService.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.mealdbapi
2 |
3 | import de.jensklingenberg.ktorfit.http.GET
4 | import de.jensklingenberg.ktorfit.http.Path
5 | import de.jensklingenberg.mealdbapi.CategoryResult
6 | import de.jensklingenberg.mealdbapi.MealResult
7 |
8 |
9 | interface MealApiService {
10 |
11 | companion object {
12 | const val baseUrl = "https://www.themealdb.com/api/json/v1/1/"
13 |
14 | }
15 |
16 | @GET("search.php?s=")
17 | suspend fun getMeals(): MealResult
18 |
19 | @GET("filter.php?c={categoryName}")
20 | suspend fun getMealsByCategory(@Path("categoryName") categoryName: String): MealResult
21 |
22 | @GET("categories.php")
23 | suspend fun getCategories(): CategoryResult
24 |
25 | @GET("search.php?s={mealName}")
26 | suspend fun getMealsByName(@Path("mealName") mealName: String): MealResult
27 |
28 | @GET("lookup.php?i={mealId}")
29 | suspend fun getMealsById(@Path("mealId") mealName: Int): MealResult
30 | }
31 |
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/detail/DetailViewModel.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.detail
2 |
3 | import androidx.compose.runtime.mutableStateOf
4 | import de.jensklingenberg.mealapp.MealDataSource
5 | import de.jensklingenberg.mealapp.network.model.Meal
6 | import kotlinx.coroutines.GlobalScope
7 | import kotlinx.coroutines.launch
8 |
9 | sealed class DetailUiState() {
10 | object Loading : DetailUiState()
11 | class Success(val meal: Meal) : DetailUiState()
12 | }
13 |
14 | class DetailViewModel(private val mealDataSource: MealDataSource) {
15 |
16 | val mealsState = mutableStateOf(DetailUiState.Loading)
17 | val isFav = mutableStateOf(false)
18 | val showFavAddedSnackbar = mutableStateOf(false)
19 | fun loadMeal(mealid: Int) {
20 | GlobalScope.launch {
21 | mealDataSource.getMealsById(mealid)?.let {
22 | mealsState.value = DetailUiState.Success(it)
23 | }
24 | }
25 | }
26 |
27 | fun addFav(on: Boolean) {
28 | isFav.value = on
29 | showFavAddedSnackbar.value = on
30 | }
31 | }
--------------------------------------------------------------------------------
/src/commonMain/kotlin/de.jensklingenberg.mealapp/MealRepository.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp
2 |
3 | import de.jensklingenberg.mealapp.mealdbapi.MealApiService
4 | import de.jensklingenberg.mealapp.network.model.Meal
5 | import de.jensklingenberg.mealapp.network.model.mapToMeal
6 | import de.jensklingenberg.mealdbapi.Category
7 |
8 |
9 | class MealRepository(private val api: MealApiService) : MealDataSource {
10 |
11 |
12 | override suspend fun getMeals(): List = api.getMeals().meals.map { it.mapToMeal() } ?: emptyList()
13 | override fun getIngredientImageUrl(name: String): String =
14 | "https://www.themealdb.com/images/ingredients/$name.png"
15 |
16 | override suspend fun getCategories(): List = api.getCategories().categories
17 | override suspend fun getMealsByCategory(categoryName: String): List =
18 | api.getMealsByCategory(categoryName).meals.map { it.mapToMeal() } ?: emptyList()
19 |
20 | override suspend fun getMealsByName(categoryName: String): List {
21 | return try {
22 | api.getMealsByName(categoryName)?.meals ?: emptyList()
23 | } catch (exception: Exception) {
24 | emptyList()
25 | }.map { it.mapToMeal() }
26 | }
27 |
28 | override suspend fun getMealsById(categoryName: Int): Meal? {
29 | return api.getMealsById(categoryName).meals.firstOrNull()
30 | ?.mapToMeal()
31 | }
32 |
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/mainpage/MealCard.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.mainpage
2 |
3 | import androidx.compose.runtime.Composable
4 | import de.jensklingenberg.mealapp.common.JKImage
5 | import de.jensklingenberg.mealapp.network.model.Meal
6 | import dev.petuska.kmdc.card.*
7 | import org.jetbrains.compose.web.attributes.AttrsScope
8 | import org.jetbrains.compose.web.css.*
9 | import org.jetbrains.compose.web.dom.Div
10 | import org.jetbrains.compose.web.dom.Text
11 | import org.w3c.dom.HTMLDivElement
12 |
13 | @Composable
14 | fun MealCard(
15 | meal: Meal,
16 | onCardClicked: (Meal) -> Unit,
17 | ) {
18 | MDCCard(attrs = {
19 | style {
20 | height(50.px)
21 | }
22 | }) {
23 | PrimaryAction {
24 | Media(type = MDCCardMediaType.Cinema) {
25 | MediaContent {
26 | //justifyContent(JustifyContent.Center)
27 | Div(attrs = fun AttrsScope.() {
28 | onClick { onCardClicked(meal) }
29 | style {
30 | display(DisplayStyle.Flex)
31 | alignItems(AlignItems.Center)
32 | //justifyContent(JustifyContent.Center)
33 | }
34 | }) {
35 | JKImage(meal.strMealThumb, 50.px)
36 | Text(meal.strMeal)
37 | }
38 | }
39 | }
40 | }
41 |
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/common/AppBar.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.common
2 |
3 | import androidx.compose.runtime.Composable
4 | import dev.petuska.kmdc.top.app.bar.*
5 | import dev.petuska.kmdcx.icons.MDCIcon
6 | import dev.petuska.kmdcx.icons.mdcIcon
7 | import org.jetbrains.compose.web.css.Position
8 | import org.jetbrains.compose.web.css.position
9 | import org.jetbrains.compose.web.dom.Div
10 | import org.jetbrains.compose.web.dom.Text
11 |
12 | @Composable
13 | fun AppBar(
14 | navigationIcon: @Composable MDCTopAppBarSectionScope.() -> Unit = {},
15 | title: String? = null,
16 | hasInfoIcon: Boolean = false,
17 | onInfoIconClicked: () -> Unit = {}
18 | ) {
19 |
20 | Div {
21 | MDCTopAppBar(type = MDCTopAppBarType.Default) {
22 | TopAppBar(attrs = {
23 | style {
24 | position(Position.Relative)
25 |
26 | }
27 | onNav { }
28 | }) {
29 |
30 | Row {
31 | Section(align = MDCTopAppBarSectionAlign.Start) {
32 |
33 | navigationIcon()
34 | title?.let {
35 | Title(it)
36 | }
37 | }
38 |
39 | Section(
40 | align = MDCTopAppBarSectionAlign.End,
41 | attrs = {
42 | attr("role", "toolbar")
43 | }
44 | ) {
45 | if(hasInfoIcon){
46 | ActionButton(attrs = {
47 | mdcIcon()
48 | onClick { onInfoIconClicked() }
49 | }) { Text(MDCIcon.Info.type) }
50 | }
51 | }
52 | }
53 | }
54 |
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/mainpage/InfoDialog.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.mainpage
2 |
3 | import androidx.compose.runtime.Composable
4 | import dev.petuska.kmdc.button.MDCButton
5 | import dev.petuska.kmdc.button.MDCButtonType
6 | import dev.petuska.kmdc.dialog.Content
7 | import dev.petuska.kmdc.dialog.MDCDialog
8 | import dev.petuska.kmdc.dialog.onClosed
9 | import org.jetbrains.compose.web.css.*
10 | import org.jetbrains.compose.web.dom.A
11 | import org.jetbrains.compose.web.dom.Div
12 | import org.jetbrains.compose.web.dom.Text
13 |
14 | @Composable
15 | fun InfoDialog(openJoinDialog: Boolean, onCloseButtonClicked: () -> Unit) {
16 | MDCDialog(open = openJoinDialog, attrs = {
17 | this.onClosed {
18 | onCloseButtonClicked()
19 | }
20 | }) {
21 |
22 | this.Content {
23 |
24 | Div {
25 | A(href = "https://github.com/Foso/KmdcExample") {
26 | Text("Source code at https://github.com/Foso/KmdcExample")
27 | }
28 | }
29 |
30 | Div {
31 | A(href = "https://github.com/mpetuska/kmdc") {
32 | Text("Created with Compose for Web and https://github.com/mpetuska/kmdc")
33 | }
34 | }
35 |
36 | Div {
37 | A(href = "https://www.themealdb.com/") {
38 | Text("Meal data is from https://www.themealdb.com/")
39 | }
40 | }
41 |
42 | Div(attrs = {
43 | style {
44 | width(100.percent)
45 | display(DisplayStyle.Flex)
46 | alignItems(AlignItems.Center)
47 | }
48 | }) {
49 | MDCButton(text = "Close", type = MDCButtonType.Raised) {
50 | onClick { onCloseButtonClicked() }
51 |
52 | }
53 | }
54 | }
55 |
56 |
57 | }
58 | }
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/App.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp
2 |
3 | import androidx.compose.runtime.getValue
4 | import androidx.compose.runtime.mutableStateOf
5 | import androidx.compose.runtime.setValue
6 | import de.jensklingenberg.ktorfit.Ktorfit
7 | import de.jensklingenberg.ktorfit.create
8 | import de.jensklingenberg.mealapp.detail.DetailPage
9 | import de.jensklingenberg.mealapp.detail.DetailViewModel
10 | import de.jensklingenberg.mealapp.mainpage.MainPage
11 | import de.jensklingenberg.mealapp.mainpage.MainPageViewModel
12 | import de.jensklingenberg.mealapp.mealdbapi.MealApiService
13 | import io.ktor.client.*
14 | import io.ktor.client.plugins.contentnegotiation.*
15 | import io.ktor.serialization.kotlinx.json.*
16 | import kotlinx.serialization.json.Json
17 | import org.jetbrains.compose.web.renderComposable
18 |
19 | class App {
20 |
21 | companion object {
22 |
23 | private val client = HttpClient {
24 | install(ContentNegotiation) {
25 | json(Json { isLenient = true; ignoreUnknownKeys = true })
26 | }
27 | }
28 |
29 | private val api = Ktorfit.Builder().baseUrl(MealApiService.baseUrl).httpClient(client).build().create()
30 | val mealDataSource: MealDataSource = MealRepository(api)
31 |
32 | }
33 |
34 | private val rootElement = "root"
35 | private var selectedPage: Page by mutableStateOf(Page.Main)
36 |
37 | init {
38 |
39 | renderComposable(rootElementId = rootElement) {
40 |
41 | when (selectedPage) {
42 | is Page.Detail -> {
43 |
44 | DetailPage(DetailViewModel(mealDataSource), (selectedPage as Page.Detail).mealId) {
45 | selectedPage = it
46 | }
47 | }
48 | is Page.Main -> {
49 | MainPage(MainPageViewModel(mealDataSource)) {
50 | selectedPage = it
51 | }
52 | }
53 | }
54 |
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/mainpage/Filter.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.mainpage
2 |
3 | import androidx.compose.runtime.*
4 | import de.jensklingenberg.mealapp.common.IconButton
5 | import dev.petuska.kmdc.checkbox.MDCCheckbox
6 | import dev.petuska.kmdc.menu.surface.MDCMenuSurface
7 | import dev.petuska.kmdc.menu.surface.MDCMenuSurfaceAnchor
8 | import dev.petuska.kmdcx.icons.MDCIcon
9 | import org.jetbrains.compose.web.attributes.AttrsScope
10 | import org.jetbrains.compose.web.css.*
11 | import org.jetbrains.compose.web.dom.Div
12 | import org.jetbrains.compose.web.dom.Text
13 | import org.w3c.dom.HTMLDivElement
14 |
15 | data class Filter(val name: String, val checked: Boolean)
16 |
17 |
18 | @Composable
19 | fun Filter(countries: List, onFilterSelected: (Int) -> Unit) {
20 |
21 | var openMenu: Boolean by remember { mutableStateOf(false) }
22 | IconButton(MDCIcon.FilterList) {
23 | openMenu = !openMenu
24 | }
25 | MDCMenuSurfaceAnchor(attrs = {
26 | style {
27 | width(10.percent)
28 | display(DisplayStyle.Flex)
29 | alignItems(AlignItems.Start)
30 | }
31 | }) {
32 |
33 | MDCMenuSurface(
34 | open = openMenu,
35 | fullWidth = true,
36 | restoreFocusOnClose = true
37 | ) {
38 | countries.forEachIndexed { index, filter ->
39 | Div(attrs = fun AttrsScope.() {
40 | onClick {
41 | onFilterSelected(index)
42 | openMenu = false
43 | }
44 | style {
45 | display(DisplayStyle.Flex)
46 | justifyContent(JustifyContent.Center)
47 | alignItems(AlignItems.Center)
48 | property("width", "fit-content")
49 | }
50 | }) {
51 | MDCCheckbox(filter.checked)
52 | Text(filter.name)
53 | }
54 |
55 |
56 | }
57 |
58 | }
59 | }
60 |
61 |
62 | }
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/mainpage/Search.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.mainpage
2 |
3 | import androidx.compose.runtime.*
4 | import de.jensklingenberg.mealapp.common.JKRaisedButton
5 |
6 | import dev.petuska.kmdc.textfield.MDCTextField
7 | import dev.petuska.kmdc.textfield.icon.MDCTextFieldTrailingIcon
8 | import dev.petuska.kmdcx.icons.MDCIcon
9 | import dev.petuska.kmdcx.icons.mdcIcon
10 | import org.jetbrains.compose.web.attributes.AttrsScope
11 | import org.jetbrains.compose.web.css.*
12 | import org.jetbrains.compose.web.dom.Div
13 | import org.jetbrains.compose.web.dom.Text
14 | import org.w3c.dom.HTMLDivElement
15 |
16 | @Composable
17 | fun Search(mainPageViewModel: MainPageViewModel) {
18 | var mytext: String by remember { mutableStateOf("") }
19 | Div(attrs = fun AttrsScope.() {
20 | style {
21 | width(100.percent)
22 | display(DisplayStyle.Flex)
23 | alignItems(AlignItems.Center)
24 | justifyContent(JustifyContent.Center)
25 | }
26 | }) {
27 | JKTextField(mytext, label = "Search", onTextChange = {
28 | mytext = it
29 | }, onEnterPressed = {
30 | mainPageViewModel.onSearch(mytext)
31 | })
32 | JKRaisedButton("Search", onClick = {
33 | mainPageViewModel.onSearch(mytext)
34 | })
35 | Filter(mainPageViewModel.filters.value) {
36 | mainPageViewModel.onFilterSelected(it)
37 | }
38 | }
39 | }
40 |
41 |
42 | @Composable
43 | fun JKTextField(value: String, label: String? = null, onTextChange: (String) -> Unit, onEnterPressed: ()->Unit) {
44 | MDCTextField(value = value, label = label, attrs = {
45 | onKeyDown {
46 | if(it.key == "Enter"){
47 | onEnterPressed()
48 | }
49 | }
50 | onInput { onTextChange(it.value) }
51 | }, trailingIcon = {
52 | if (value.isNotEmpty()) {
53 | MDCTextFieldTrailingIcon(clickable = true, attrs = {
54 | mdcIcon()
55 | onClick { onTextChange("") }
56 | }) { Text(MDCIcon.Search.type) }
57 | }
58 | })
59 | }
60 |
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/common/Components.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.common
2 |
3 | import androidx.compose.runtime.Composable
4 | import dev.petuska.kmdc.button.MDCButton
5 | import dev.petuska.kmdc.button.MDCButtonType
6 | import dev.petuska.kmdc.icon.button.Icon
7 | import dev.petuska.kmdc.icon.button.MDCIconButton
8 | import dev.petuska.kmdc.icon.button.onChange
9 | import dev.petuska.kmdc.snackbar.Label
10 | import dev.petuska.kmdc.snackbar.MDCSnackbar
11 | import dev.petuska.kmdc.textfield.MDCTextField
12 | import dev.petuska.kmdc.textfield.icon.MDCTextFieldTrailingIcon
13 | import dev.petuska.kmdcx.icons.MDCIcon
14 | import dev.petuska.kmdcx.icons.mdcIcon
15 | import org.jetbrains.compose.web.attributes.AttrsScope
16 | import org.jetbrains.compose.web.css.CSSNumeric
17 | import org.jetbrains.compose.web.css.height
18 | import org.jetbrains.compose.web.dom.AttrBuilderContext
19 | import org.jetbrains.compose.web.dom.Div
20 | import org.jetbrains.compose.web.dom.Img
21 | import org.jetbrains.compose.web.dom.Text
22 | import org.w3c.dom.HTMLDivElement
23 | import org.w3c.dom.HTMLElement
24 |
25 | @Composable
26 | fun JKRaisedButton(text: String, onClick: () -> Unit) {
27 | MDCButton(text = text, type = MDCButtonType.Raised) {
28 | height("200px")
29 | onClick { onClick() }
30 | }
31 | }
32 |
33 |
34 | fun AttrsScope.height(s: String) {
35 | attr("height", s)
36 | }
37 |
38 | @Composable
39 | fun JKSnackbar(text: String) {
40 | MDCSnackbar(
41 | closeOnEscape = true,
42 | timeoutMs = 2000,
43 | open = true,
44 | attrs = {
45 |
46 | }
47 | ) {
48 | Label(text)
49 |
50 | }
51 | }
52 |
53 | @Composable
54 | fun JKImage(src: String, height: CSSNumeric, alt: String = "") {
55 | Img(src, alt = alt, attrs = {
56 | style {
57 | height(height)
58 | }
59 | })
60 | }
61 |
62 |
63 | @Composable
64 | fun HeightSpacer(value: CSSNumeric) {
65 | Div(attrs = {
66 | style {
67 | height(value)
68 | }
69 | }) {
70 |
71 | }
72 | }
73 |
74 | fun AttrsScope.ariaDescribedBy(id: String) {
75 | attr("aria-describedby", id)
76 | }
77 |
78 |
79 | @Composable
80 | fun IconButton(onIcon: MDCIcon, offIcon: MDCIcon = onIcon, onChange: () -> Unit) {
81 | MDCIconButton(true, attrs = {
82 | style {
83 |
84 | }
85 | onChange { onChange() }
86 | }) {
87 |
88 | Icon(on = true, attrs = {
89 |
90 | mdcIcon()
91 | }) {
92 | Text(onIcon.type)
93 | }
94 | Icon(on = false, attrs = {
95 |
96 | mdcIcon()
97 | }) {
98 | Text(offIcon.type)
99 | }
100 |
101 |
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/mainpage/MainPage.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.mainpage
2 |
3 | import androidx.compose.runtime.*
4 | import de.jensklingenberg.mealapp.Page
5 | import de.jensklingenberg.mealapp.common.*
6 | import dev.petuska.kmdc.chips.grid.InputChip
7 | import dev.petuska.kmdc.chips.grid.MDCChipsGrid
8 | import dev.petuska.kmdc.chips.grid.PrimaryAction
9 | import dev.petuska.kmdc.circular.progress.MDCCircularProgress
10 | import dev.petuska.kmdc.tooltip.MDCTooltip
11 | import org.jetbrains.compose.web.attributes.AttrsScope
12 | import org.jetbrains.compose.web.css.*
13 | import org.jetbrains.compose.web.dom.Div
14 | import org.jetbrains.compose.web.dom.Text
15 | import org.w3c.dom.HTMLDivElement
16 |
17 |
18 | @Composable
19 | fun MainPage(mainPageViewModel: MainPageViewModel, onChangePage: (Page) -> Unit) {
20 |
21 | var openDialog: Boolean by remember { mutableStateOf(false) }
22 |
23 |
24 | Div {
25 | InfoDialog(openDialog) {
26 | openDialog = false
27 | }
28 | AppBar(onInfoIconClicked = {
29 | openDialog = !openDialog
30 | }, hasInfoIcon = true)
31 | Div(attrs = {
32 | style {
33 | textAlign("center")
34 | display(DisplayStyle.Inline)
35 | alignItems(AlignItems.Center)
36 | justifyContent(JustifyContent.Center)
37 | }
38 | }) {
39 | Search(mainPageViewModel)
40 | }
41 | Div(attrs = fun AttrsScope.() {
42 | style {
43 | width(100.percent)
44 | display(DisplayStyle.Flex)
45 | justifyContent(JustifyContent.Center)
46 | }
47 | }) {
48 | ChipsGrid(mainPageViewModel)
49 | }
50 | when (val state = mainPageViewModel.mealsState.value) {
51 | MainpageUiState.Loading -> {
52 | Div {
53 | MDCCircularProgress()
54 | }
55 | }
56 | is MainpageUiState.Success -> {
57 | state.meals.forEach { meal ->
58 | MealCard(meal) {
59 | onChangePage(Page.Detail(meal.idMeal))
60 | }
61 | HeightSpacer(20.px)
62 | }
63 | }
64 | MainpageUiState.Error -> {
65 | Text("Nothing found")
66 | }
67 | }
68 | }
69 | }
70 |
71 | @Composable
72 | fun ChipsGrid(mainPageViewModel: MainPageViewModel) {
73 | MDCChipsGrid {
74 | mainPageViewModel.categories.value.forEachIndexed { index, category ->
75 | val toolId = "tooltip_$index"
76 | MDCTooltip(toolId, text = category.strCategoryDescription)
77 | InputChip(index.toString(), attrs = {
78 | ariaDescribedBy(toolId)
79 | }) {
80 | PrimaryAction(attrs = {
81 | onClick { mainPageViewModel.onCategorySelected(category.strCategory) }
82 | }) {
83 | Text(category.strCategory)
84 | }
85 | }
86 | }
87 | }
88 | }
89 |
90 |
91 |
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/mainpage/MainPageViewModel.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.mainpage
2 |
3 | import androidx.compose.runtime.mutableStateOf
4 | import de.jensklingenberg.mealapp.MealDataSource
5 | import de.jensklingenberg.mealapp.network.model.Meal
6 | import kotlinx.coroutines.GlobalScope
7 | import kotlinx.coroutines.launch
8 |
9 | sealed class MainpageUiState {
10 | class Success(val meals: List) : MainpageUiState()
11 | object Loading : MainpageUiState()
12 | object Error : MainpageUiState()
13 | }
14 |
15 | class MainPageViewModel(private val mealDataSource: MealDataSource) {
16 | val mealsState = mutableStateOf(MainpageUiState.Loading)
17 | val categories = mutableStateOf>(emptyList())
18 |
19 | private var searchResults = listOf()
20 |
21 | private val countries = listOf(
22 | "American",
23 | "British",
24 | "Canadian",
25 | "Chinese",
26 | "Croatian",
27 | "Dutch",
28 | "Egyptian",
29 | "French",
30 | "Greek",
31 | "Indian",
32 | "Irish",
33 | "Italian",
34 | "Jamaican",
35 | "Japanese",
36 | "Kenyan",
37 | "Malaysian",
38 | "Mexican",
39 | "Moroccan",
40 | "Polish",
41 | "Portuguese",
42 | "Russian",
43 | "Spanish",
44 | "Thai",
45 | "Tunisian",
46 | "Turkish",
47 | "Unknown",
48 | "Vietnamese"
49 | )
50 |
51 | val filters = mutableStateOf>(countries.map { Filter(it, false) })
52 |
53 |
54 | init {
55 | getMeals()
56 | loadCategories()
57 | }
58 |
59 | private fun getMeals() {
60 | mealsState.value = MainpageUiState.Loading
61 | GlobalScope.launch {
62 | val meals = mealDataSource.getMeals()
63 | console.log("SIZE" + meals.size)
64 | if (meals.isEmpty()) {
65 | mealsState.value = MainpageUiState.Error
66 | } else {
67 | val results = mealDataSource.getMeals()
68 | searchResults = results
69 | mealsState.value = MainpageUiState.Success((results))
70 | }
71 | }
72 | }
73 |
74 | private fun loadCategories() {
75 |
76 | GlobalScope.launch {
77 | categories.value = mealDataSource.getCategories()
78 | }
79 | }
80 |
81 | fun onSearch(name: String) {
82 | mealsState.value = MainpageUiState.Loading
83 | GlobalScope.launch {
84 | val meals = mealDataSource.getMealsByName(name)
85 |
86 | if (meals.isEmpty()) {
87 | mealsState.value = MainpageUiState.Error
88 | } else {
89 | searchResults = meals
90 | mealsState.value = MainpageUiState.Success((meals))
91 | }
92 | }
93 | }
94 |
95 | fun onCategorySelected(idCategory: String) {
96 | mealsState.value = MainpageUiState.Loading
97 | GlobalScope.launch {
98 | mealsState.value = MainpageUiState.Success((mealDataSource.getMealsByCategory(idCategory)))
99 | }
100 | }
101 |
102 | fun onFilterSelected(it: Int) {
103 | val checked = filters.value[it].checked
104 |
105 | filters.value = filters.value.mapIndexed { index, filter ->
106 | if (it == index) {
107 | Filter(filter.name, !checked)
108 | } else {
109 | Filter(filter.name, filter.checked)
110 | }
111 | }
112 | updateSearchResults()
113 | }
114 |
115 | private fun updateSearchResults() {
116 | mealsState.value = if (filters.value.any { it.checked }) {
117 | val results =
118 | searchResults.filter { result -> filters.value.filter { it.checked }.any { it.name == result.strArea } }
119 | MainpageUiState.Success((results))
120 | } else {
121 | MainpageUiState.Success((searchResults))
122 | }
123 | }
124 | }
--------------------------------------------------------------------------------
/src/jsMain/kotlin/de.jensklingenberg.mealapp/detail/DetailPage.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealapp.detail
2 |
3 | import androidx.compose.runtime.Composable
4 | import androidx.compose.runtime.LaunchedEffect
5 | import de.jensklingenberg.mealapp.Page
6 | import de.jensklingenberg.mealapp.common.AppBar
7 | import de.jensklingenberg.mealapp.common.JKImage
8 | import de.jensklingenberg.mealapp.common.JKSnackbar
9 | import de.jensklingenberg.mealdbapi.Ingredient
10 | import dev.petuska.kmdc.chips.grid.InputChip
11 | import dev.petuska.kmdc.chips.grid.MDCChipsGrid
12 | import dev.petuska.kmdc.chips.grid.PrimaryAction
13 | import dev.petuska.kmdc.circular.progress.MDCCircularProgress
14 | import dev.petuska.kmdc.data.table.*
15 | import dev.petuska.kmdc.icon.button.Icon
16 | import dev.petuska.kmdc.icon.button.MDCIconButton
17 | import dev.petuska.kmdc.icon.button.onChange
18 | import dev.petuska.kmdc.top.app.bar.ActionButton
19 | import dev.petuska.kmdc.typography.MDCH1
20 | import dev.petuska.kmdc.typography.MDCH2
21 | import dev.petuska.kmdcx.icons.MDCIcon
22 | import dev.petuska.kmdcx.icons.mdcIcon
23 | import org.jetbrains.compose.web.attributes.AttrsScope
24 | import org.jetbrains.compose.web.css.*
25 | import org.jetbrains.compose.web.dom.Div
26 | import org.jetbrains.compose.web.dom.Text
27 | import org.w3c.dom.HTMLDivElement
28 |
29 | @Composable
30 | fun DetailPage(detailViewModel: DetailViewModel, mealId: Int, onChangePage: (Page) -> Unit) {
31 | LaunchedEffect(Unit) {
32 | detailViewModel.loadMeal(mealId)
33 | }
34 |
35 | Div(attrs = {
36 | style {
37 | textAlign("center")
38 | //display(DisplayStyle.Flex)
39 | alignItems(AlignItems.Center)
40 | justifyContent(JustifyContent.Center)
41 | }
42 | }) {
43 |
44 | when (val uiState = detailViewModel.mealsState.value) {
45 | DetailUiState.Loading -> {
46 | Div {
47 | MDCCircularProgress()
48 | }
49 | }
50 | is DetailUiState.Success -> {
51 | val meal = uiState.meal
52 | if (detailViewModel.showFavAddedSnackbar.value) {
53 | JKSnackbar("Recipe added")
54 | }
55 | AppBar(
56 | navigationIcon = {
57 | ActionButton(attrs = {
58 | mdcIcon()
59 | onClick {
60 | onChangePage(Page.Main)
61 | }
62 | }) { Text(MDCIcon.ArrowBack.type) }
63 | },
64 | title = meal.strMeal
65 | )
66 |
67 | Div {
68 | MDCH1(meal.strMeal)
69 | JKImage(meal.strMealThumb, alt = meal.strMeal, height = 200.px)
70 | MDCChipsGrid(attrs = {
71 | style {
72 | justifyContent(JustifyContent.Center)
73 | }
74 | }) {
75 | listOfNotNull(meal.strCategory, meal.strArea).filter { it.isNotEmpty() }
76 | .forEachIndexed { index, category ->
77 |
78 | InputChip(index.toString()) {
79 | PrimaryAction() {
80 | Text(category)
81 | }
82 | }
83 | }
84 | }
85 | }
86 |
87 |
88 | MDCIconButton(detailViewModel.isFav.value, attrs = {
89 | onChange { detailViewModel.addFav(it.detail.isOn) }
90 | }) {
91 | if (detailViewModel.isFav.value) {
92 | Icon(on = true, attrs = {
93 |
94 | mdcIcon()
95 | }) {
96 | Text(MDCIcon.Favorite.type)
97 | }
98 | } else {
99 | Icon(on = false, attrs = { mdcIcon() }) {
100 | Text(MDCIcon.FavoriteBorder.type)
101 | }
102 | }
103 |
104 |
105 | }
106 | IngredientTable(meal.ingredients)
107 | MDCH2("Ingredients")
108 |
109 |
110 | Div(attrs = fun AttrsScope.() {
111 | style {
112 | display(DisplayStyle.Flex)
113 | marginLeft(10.percent)
114 | marginRight(10.percent)
115 |
116 | }
117 | }) {
118 | Text(meal.strInstructions)
119 | }
120 |
121 |
122 | }
123 | }
124 |
125 | }
126 |
127 |
128 | }
129 |
130 | @Composable
131 | fun IngredientTable(it: List) {
132 | MDCDataTable {
133 | Container {
134 | MDCDataTableHeader {
135 | Cell("Ingredient")
136 | Cell("Amount")
137 | }
138 | Body {
139 | it.forEach {
140 | Row {
141 | Cell(it.name)
142 | Cell(it.measure)
143 | }
144 | }
145 |
146 | }
147 | }
148 | }
149 | }
--------------------------------------------------------------------------------
/docs/KmdcTest.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Copyright 2016 Google Inc.
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | */
23 |
24 | /**
25 | * @license
26 | * Copyright 2017 Google Inc.
27 | *
28 | * Permission is hereby granted, free of charge, to any person obtaining a copy
29 | * of this software and associated documentation files (the "Software"), to deal
30 | * in the Software without restriction, including without limitation the rights
31 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32 | * copies of the Software, and to permit persons to whom the Software is
33 | * furnished to do so, subject to the following conditions:
34 | *
35 | * The above copyright notice and this permission notice shall be included in
36 | * all copies or substantial portions of the Software.
37 | *
38 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44 | * THE SOFTWARE.
45 | */
46 |
47 | /**
48 | * @license
49 | * Copyright 2018 Google Inc.
50 | *
51 | * Permission is hereby granted, free of charge, to any person obtaining a copy
52 | * of this software and associated documentation files (the "Software"), to deal
53 | * in the Software without restriction, including without limitation the rights
54 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
55 | * copies of the Software, and to permit persons to whom the Software is
56 | * furnished to do so, subject to the following conditions:
57 | *
58 | * The above copyright notice and this permission notice shall be included in
59 | * all copies or substantial portions of the Software.
60 | *
61 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
64 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
66 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
67 | * THE SOFTWARE.
68 | */
69 |
70 | /**
71 | * @license
72 | * Copyright 2019 Google Inc.
73 | *
74 | * Permission is hereby granted, free of charge, to any person obtaining a copy
75 | * of this software and associated documentation files (the "Software"), to deal
76 | * in the Software without restriction, including without limitation the rights
77 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
78 | * copies of the Software, and to permit persons to whom the Software is
79 | * furnished to do so, subject to the following conditions:
80 | *
81 | * The above copyright notice and this permission notice shall be included in
82 | * all copies or substantial portions of the Software.
83 | *
84 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
87 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
88 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
89 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
90 | * THE SOFTWARE.
91 | */
92 |
93 | /**
94 | * @license
95 | * Copyright 2020 Google Inc.
96 | *
97 | * Permission is hereby granted, free of charge, to any person obtaining a copy
98 | * of this software and associated documentation files (the "Software"), to deal
99 | * in the Software without restriction, including without limitation the rights
100 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
101 | * copies of the Software, and to permit persons to whom the Software is
102 | * furnished to do so, subject to the following conditions:
103 | *
104 | * The above copyright notice and this permission notice shall be included in
105 | * all copies or substantial portions of the Software.
106 | *
107 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
108 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
109 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
110 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
111 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
112 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
113 | * THE SOFTWARE.
114 | */
115 |
--------------------------------------------------------------------------------
/src/commonMain/kotlin/de.jensklingenberg.mealapp/mealdbapi/MealResult.kt:
--------------------------------------------------------------------------------
1 | package de.jensklingenberg.mealdbapi
2 |
3 | import kotlinx.serialization.Serializable
4 |
5 | data class Ingredient(val name: String, val measure: String = "")
6 |
7 | fun ApiMeal.tags(): List {
8 | return strTags?.split(",") ?: emptyList()
9 | }
10 |
11 | fun ApiMeal.getIngredients(): List {
12 | val ingredientsList = mutableListOf()
13 | strIngredient1?.let {
14 | if (it.isNotBlank()) {
15 | ingredientsList.add(Ingredient(it, strMeasure1 ?: ""))
16 | }
17 | }
18 |
19 | strIngredient2?.let {
20 | if (it.isNotBlank()) {
21 | ingredientsList.add(Ingredient(it, strMeasure2 ?: ""))
22 |
23 | }
24 | }
25 | strIngredient3?.let {
26 | if (it.isNotBlank()) {
27 | ingredientsList.add(Ingredient(it, strMeasure3 ?: ""))
28 |
29 | }
30 | }
31 | strIngredient4?.let {
32 | if (it.isNotBlank()) {
33 | ingredientsList.add(Ingredient(it, strMeasure4 ?: ""))
34 |
35 | }
36 | }
37 | strIngredient5?.let {
38 | if (it.isNotBlank()) {
39 | ingredientsList.add(Ingredient(it, strMeasure5 ?: ""))
40 |
41 | }
42 | }
43 | strIngredient6?.let {
44 | if (it.isNotBlank()) {
45 | ingredientsList.add(Ingredient(it, strMeasure6 ?: ""))
46 |
47 | }
48 | }
49 | strIngredient7?.let {
50 | if (it.isNotBlank()) {
51 | ingredientsList.add(Ingredient(it, strMeasure7 ?: ""))
52 |
53 | }
54 | }
55 | strIngredient8?.let {
56 | if (it.isNotBlank()) {
57 | ingredientsList.add(Ingredient(it, strMeasure8 ?: ""))
58 |
59 | }
60 | }
61 | strIngredient9?.let {
62 | if (it.isNotBlank()) {
63 | ingredientsList.add(Ingredient(it, strMeasure9 ?: ""))
64 |
65 | }
66 | }
67 | strIngredient10?.let {
68 | if (it.isNotBlank()) {
69 | ingredientsList.add(Ingredient(it, strMeasure10 ?: ""))
70 |
71 | }
72 | }
73 | strIngredient11?.let {
74 | if (it.isNotBlank()) {
75 | ingredientsList.add(Ingredient(it, strMeasure11 ?: ""))
76 |
77 | }
78 | }
79 | strIngredient12?.let {
80 | if (it.isNotBlank()) {
81 | ingredientsList.add(Ingredient(it, strMeasure12 ?: ""))
82 |
83 | }
84 | }
85 | strIngredient13?.let {
86 | if (it.isNotBlank()) {
87 | ingredientsList.add(Ingredient(it, strMeasure13 ?: ""))
88 |
89 | }
90 | }
91 | strIngredient14?.let {
92 | if (it.isNotBlank()) {
93 | ingredientsList.add(Ingredient(it, strMeasure14 ?: ""))
94 |
95 | }
96 | }
97 | strIngredient15?.let {
98 | if (it.isNotBlank()) {
99 | ingredientsList.add(Ingredient(it, strMeasure15 ?: ""))
100 |
101 | }
102 | }
103 | strIngredient16?.let {
104 | if (it.isNotBlank()) {
105 | ingredientsList.add(Ingredient(it, strMeasure16 ?: ""))
106 |
107 | }
108 | }
109 | strIngredient17?.let {
110 | if (it.isNotBlank()) {
111 | ingredientsList.add(Ingredient(it, strMeasure17 ?: ""))
112 |
113 | }
114 | }
115 | strIngredient18?.let {
116 | if (it.isNotBlank()) {
117 | ingredientsList.add(Ingredient(it, strMeasure18 ?: ""))
118 |
119 | }
120 | }
121 | strIngredient19?.let {
122 | if (it.isNotBlank()) {
123 | ingredientsList.add(Ingredient(it, strMeasure19 ?: ""))
124 |
125 | }
126 | }
127 | strIngredient20?.let {
128 | if (it.isNotBlank()) {
129 | ingredientsList.add(Ingredient(it, strMeasure20 ?: ""))
130 |
131 | }
132 | }
133 | return ingredientsList
134 | }
135 |
136 | /**
137 | * Dto from meal api
138 | */
139 | @kotlinx.serialization.Serializable
140 |
141 | data class ApiMeal(
142 | var strMeal: String,
143 | var idMeal: Int,
144 | var strMealThumb: String,
145 | var strIngredient1: String? = "",
146 | var strIngredient2: String? = "",
147 | var strIngredient3: String? = "",
148 | var strIngredient4: String? = "",
149 | var strIngredient5: String? = "",
150 | var strIngredient6: String? = "",
151 | var strIngredient7: String? = "",
152 | var strIngredient8: String? = "",
153 | var strIngredient9: String? = "",
154 | var strIngredient10: String? = "",
155 | var strIngredient11: String? = "",
156 | var strIngredient12: String? = "",
157 | var strIngredient13: String? = "",
158 | var strIngredient14: String? = "",
159 | var strIngredient15: String? = "",
160 | var strIngredient16: String? = "",
161 | var strIngredient17: String? = "",
162 | var strIngredient18: String? = "",
163 | var strIngredient19: String? = "",
164 | var strIngredient20: String? = "",
165 | var strMeasure1: String? = "",
166 | var strMeasure2: String? = "",
167 | var strMeasure3: String? = "",
168 | var strMeasure4: String? = "",
169 | var strMeasure5: String? = "",
170 | var strMeasure6: String? = "",
171 | var strMeasure7: String? = "",
172 | var strMeasure8: String? = "",
173 | var strMeasure9: String? = "",
174 | var strMeasure10: String? = "",
175 | var strMeasure11: String? = "",
176 | var strMeasure12: String? = "",
177 | var strMeasure13: String? = "",
178 | var strArea: String? = "",
179 |
180 | var strMeasure14: String? = "",
181 | var strMeasure15: String? = "",
182 | var strMeasure16: String? = "",
183 | var strMeasure17: String? = "",
184 | var strMeasure18: String? = "",
185 | var strMeasure19: String? = "",
186 | var strMeasure20: String? = "",
187 | var strTags: String? = "",
188 | var strCategory: String = "",
189 | var strInstructions: String = ""
190 | )
191 |
192 |
193 | @Serializable
194 | data class MealResult(
195 | val meals: List = emptyList(),
196 | )
197 |
198 | @Serializable
199 | data class CategoryResult(
200 | val categories: List,
201 | )
202 |
203 | @Serializable
204 | data class Category(
205 | var idCategory: String,
206 | var strCategory: String,
207 | var strCategoryThumb: String,
208 | var strCategoryDescription: String,
209 | )
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/License.md:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [2022] [Jens Klingenberg]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------