sample/src/desktopMain/kotlin/main.kt
author Da Risk <da_risk@geekorum.com>
Fri, 02 May 2025 16:59:15 -0400
changeset 70 252e1a0104e4
parent 50 baa92ecc2001
permissions -rw-r--r--
build: add github publish workflow
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     1
/*
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     2
 * AboutOss is an utility library to retrieve and display
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     3
 * opensource licenses in Android applications.
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     4
 *
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     5
 * Copyright (C) 2023-2025 by Frederic-Charles Barthelery.
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     6
 *
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     7
 * This file is part of AboutOss.
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     8
 *
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     9
 * AboutOss is free software: you can redistribute it and/or modify
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    10
 * it under the terms of the GNU General Public License as published by
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    11
 * the Free Software Foundation, either version 3 of the License, or
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    12
 * (at your option) any later version.
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    13
 *
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    14
 * AboutOss is distributed in the hope that it will be useful,
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    17
 * GNU General Public License for more details.
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    18
 *
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    19
 * You should have received a copy of the GNU General Public License
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    20
 * along with AboutOss.  If not, see <http://www.gnu.org/licenses/>.
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    21
 */
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    22
package com.geekorum.aboutoss.sampleapp
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    23
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    24
import androidx.compose.runtime.Composable
50
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    25
import androidx.compose.runtime.getValue
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    26
import androidx.compose.runtime.mutableStateOf
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    27
import androidx.compose.runtime.remember
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    28
import androidx.compose.runtime.setValue
47
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    29
import androidx.compose.ui.window.Window
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    30
import androidx.compose.ui.window.application
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    31
import org.jetbrains.compose.ui.tooling.preview.Preview
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    32
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    33
@Composable
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    34
@Preview
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    35
fun SampleAppDesktop() {
50
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    36
    var material2IsOpen by remember { mutableStateOf(false) }
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    37
    var material3IsOpen by remember { mutableStateOf(false) }
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    38
    SampleApp(
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    39
        onMaterial2Click = {
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    40
            material2IsOpen = true
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    41
        },
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    42
        onMaterial3Click = {
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    43
            material3IsOpen = true
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    44
        })
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    45
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    46
    if (material2IsOpen) {
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    47
        PrebuiltLicencesMaterial2Window(onCloseRequest = {
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    48
            material2IsOpen = false
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    49
        })
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    50
    }
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    51
    if (material3IsOpen) {
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    52
        PrebuiltLicencesMaterial3Window(onCloseRequest = {
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    53
            material3IsOpen = false
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    54
        })
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    55
    }
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    56
47
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    57
}
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    58
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    59
fun main() = application {
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    60
    Window(onCloseRequest = ::exitApplication) {
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    61
        SampleAppDesktop()
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    62
    }
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    63
}