sample/src/desktopMain/kotlin/PrebuiltLicensesViewModel.desktop.kt
author Da Risk <da_risk@geekorum.com>
Thu, 24 Apr 2025 18:12:44 -0400
changeset 52 4e2dd3a58b74
parent 50 baa92ecc2001
child 54 3377ea7d1f03
permissions -rw-r--r--
ui:material2: use BrowserLauncher
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.lifecycle.viewmodel.CreationExtras
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    25
import com.geekorum.aboutoss.core.licensee.LicenseeLicenseInfoRepository
50
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    26
import com.geekorum.aboutoss.ui.common.DesktopBrowserLauncher
47
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    27
import com.geekorum.aboutoss.ui.common.OpenSourceLicensesViewModel
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    28
import kotlinx.coroutines.Dispatchers
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    29
import org.jetbrains.compose.resources.ExperimentalResourceApi
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    30
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    31
@OptIn(ExperimentalResourceApi::class)
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    32
actual fun CreationExtras.createPrebuildOpenSourceLicensesViewModel(): OpenSourceLicensesViewModel {
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    33
    val licenseInfoRepository = LicenseeLicenseInfoRepository(
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    34
        mainCoroutineDispatcher = Dispatchers.Main,
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    35
        ioCoroutineDispatcher = Dispatchers.IO,
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    36
        licenseeResourcePath = "app/cash/licensee/prebuilt_artifacts.json",
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    37
    )
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    38
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    39
    return OpenSourceLicensesViewModel(
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    40
        licenseInfoRepository,
50
baa92ecc2001 sample: add PrebuiltLicensesWindows for desktop
Da Risk <da_risk@geekorum.com>
parents: 47
diff changeset
    41
        DesktopBrowserLauncher()
47
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    42
    )
246422783c0c sample: extract base of sample to common. start implementing desktop
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    43
}