1 /*
2 * Copyright (C) 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.android.avatarpicker.ui.bottombar
18
19 import androidx.compose.foundation.layout.Arrangement
20 import androidx.compose.foundation.layout.Column
21 import androidx.compose.foundation.layout.Row
22 import androidx.compose.foundation.layout.fillMaxHeight
23 import androidx.compose.foundation.layout.fillMaxWidth
24 import androidx.compose.foundation.layout.padding
25 import androidx.compose.material.Divider
26 import androidx.compose.material3.Button
27 import androidx.compose.material3.ButtonColors
28 import androidx.compose.material3.MaterialTheme
29 import androidx.compose.material3.Text
30 import androidx.compose.runtime.Composable
31 import androidx.compose.ui.Alignment
32 import androidx.compose.ui.Modifier
33 import androidx.compose.ui.res.stringResource
34 import androidx.compose.ui.unit.dp
35 import com.android.avatarpicker.R
36
37 @Composable
BottomActionBarnull38 fun BottomActionBar(
39 doneEndabled: Boolean, onSuccess: () -> Unit, onFail: () -> Unit
40 ) {
41
42 Column(Modifier.fillMaxWidth().fillMaxHeight()) {
43 Divider(
44 Modifier.fillMaxWidth(),
45 color = MaterialTheme.colorScheme.outlineVariant,
46 thickness = 1.dp,
47 startIndent = 0.dp
48 )
49 Row(
50 Modifier.fillMaxWidth().fillMaxHeight().padding(start = 24.dp, end = 24.dp),
51 horizontalArrangement = Arrangement.spacedBy(
52 8.dp, Alignment.End
53 ),
54 verticalAlignment = Alignment.CenterVertically,
55 ) {
56 Button(
57 onClick = onFail, colors = ButtonColors(
58 containerColor = MaterialTheme.colorScheme.surfaceContainer,
59 contentColor = MaterialTheme.colorScheme.primary,
60 disabledContainerColor = MaterialTheme.colorScheme.surfaceContainer,
61 disabledContentColor = MaterialTheme.colorScheme.primary.copy(.12f)
62 )
63 ) {
64 Text(text = stringResource(R.string.cancel))
65 }
66
67 Button(
68 onClick = {
69 onSuccess()
70 }, colors = ButtonColors(
71 containerColor = MaterialTheme.colorScheme.primary,
72 contentColor = MaterialTheme.colorScheme.surfaceContainer,
73 disabledContainerColor = MaterialTheme.colorScheme.primary.copy(.12f),
74 disabledContentColor = MaterialTheme.colorScheme.onPrimary
75 ), enabled = doneEndabled
76 ) {
77 Text(text = stringResource(R.string.done))
78 }
79 }
80 }
81 }