mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-20 01:05:26 +02:00
NavigateUpButton as a reusable component
This commit is contained in:
parent
c43d6bb4c5
commit
685a3dfc56
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Unitto is a unit converter for Android
|
||||||
|
* Copyright (c) 2022 Elshan Agaev
|
||||||
|
*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sadellie.unitto.screens.common
|
||||||
|
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.ArrowBack
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import com.sadellie.unitto.R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button that is used in Top bars
|
||||||
|
*
|
||||||
|
* @param onClick Action to be called when button is clicked.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
fun NavigateUpButton(onClick: () -> Unit) {
|
||||||
|
IconButton(onClick = onClick) {
|
||||||
|
Icon(
|
||||||
|
Icons.Outlined.ArrowBack,
|
||||||
|
contentDescription = stringResource(id = R.string.navigate_up_description)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -20,10 +20,6 @@ package com.sadellie.unitto.screens.common
|
|||||||
|
|
||||||
import androidx.compose.animation.rememberSplineBasedDecay
|
import androidx.compose.animation.rememberSplineBasedDecay
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.outlined.ArrowBack
|
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.LargeTopAppBar
|
import androidx.compose.material3.LargeTopAppBar
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@ -32,8 +28,6 @@ import androidx.compose.material3.rememberTopAppBarScrollState
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.res.stringResource
|
|
||||||
import com.sadellie.unitto.R
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commonly used LargeTopAppBar with scroll behavior.
|
* Commonly used LargeTopAppBar with scroll behavior.
|
||||||
@ -61,9 +55,7 @@ fun UnittoLargeTopAppBar(
|
|||||||
Text(text = title)
|
Text(text = title)
|
||||||
},
|
},
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = navigateUpAction) {
|
NavigateUpButton { navigateUpAction() }
|
||||||
Icon(Icons.Outlined.ArrowBack, stringResource(R.string.navigate_up_description))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
scrollBehavior = scrollBehavior
|
scrollBehavior = scrollBehavior
|
||||||
)
|
)
|
||||||
|
@ -38,7 +38,6 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.filled.Favorite
|
import androidx.compose.material.icons.filled.Favorite
|
||||||
import androidx.compose.material.icons.filled.FavoriteBorder
|
import androidx.compose.material.icons.filled.FavoriteBorder
|
||||||
import androidx.compose.material.icons.filled.Search
|
import androidx.compose.material.icons.filled.Search
|
||||||
import androidx.compose.material.icons.outlined.ArrowBack
|
|
||||||
import androidx.compose.material.icons.outlined.Clear
|
import androidx.compose.material.icons.outlined.Clear
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@ -63,6 +62,7 @@ import androidx.compose.ui.graphics.SolidColor
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import com.sadellie.unitto.R
|
import com.sadellie.unitto.R
|
||||||
|
import com.sadellie.unitto.screens.common.NavigateUpButton
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search bar on the Second screen. Controls what will be shown in the list above this component
|
* Search bar on the Second screen. Controls what will be shown in the list above this component
|
||||||
@ -170,12 +170,7 @@ fun SearchBar(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = { stagedNavigateUp() }) {
|
NavigateUpButton { stagedNavigateUp() }
|
||||||
Icon(
|
|
||||||
Icons.Outlined.ArrowBack,
|
|
||||||
contentDescription = stringResource(id = R.string.navigate_up_description)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
scrollBehavior = scrollBehavior
|
scrollBehavior = scrollBehavior
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user