Skip to content

Commit

Permalink
Add generic launchActivity extension
Browse files Browse the repository at this point in the history
  • Loading branch information
LunarX committed Aug 15, 2024
1 parent fd7c803 commit f3fc25e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package com.infomaniak.swisstransfer.ui.components

import android.content.Intent
import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.FloatingActionButtonElevation
import androidx.compose.runtime.Composable
Expand All @@ -27,6 +26,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.infomaniak.swisstransfer.ui.NewTransferActivity
import com.infomaniak.swisstransfer.ui.utils.launchActivity

@Composable
fun NewTransferFab(
Expand All @@ -38,7 +38,7 @@ fun NewTransferFab(
modifier = modifier,
fabType = mainScreenFabType.fabType,
elevation = mainScreenFabType.elevation(),
onClick = { context.startActivity(Intent(context, NewTransferActivity::class.java)) },
onClick = { context.launchActivity(NewTransferActivity::class) },
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Infomaniak SwissTransfer - Android
* Copyright (C) 2024 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.infomaniak.swisstransfer.ui.utils

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import kotlin.reflect.KClass


fun <T : Activity> Context.launchActivity(kClass: KClass<T>, options: Bundle? = null) {
startActivity(Intent(this, kClass.java), options)
}

0 comments on commit f3fc25e

Please sign in to comment.