[go: nahoru, domu]

blob: e6ccf50fdf90dfdb5996af56fd9d73217c507719 [file] [log] [blame]
/*
* Copyright 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.ui.material.studies.rally
import androidx.compose.Composable
import androidx.ui.core.Alignment
import androidx.ui.core.Modifier
import androidx.compose.foundation.Text
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Stack
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredHeight
import androidx.ui.material.Card
import androidx.ui.material.MaterialTheme
import androidx.ui.unit.dp
/**
* The Accounts screen.
*/
@Composable
fun AccountsBody(accounts: List<Account>) {
Stack(Modifier.verticalScroll(rememberScrollState(0f)).padding(16.dp)) {
val accountsProportion = accounts.extractProportions { it.balance }
val colors = accounts.map { it.color }
AnimatedCircle(
Modifier.preferredHeight(300.dp).gravity(Alignment.Center).fillMaxWidth(),
accountsProportion,
colors
)
Column(modifier = Modifier.gravity(Alignment.Center)) {
Text(
text = "Total",
style = MaterialTheme.typography.body1,
modifier = Modifier.gravity(Alignment.CenterHorizontally)
)
Text(
text = "$12,132.49",
style = MaterialTheme.typography.h2,
modifier = Modifier.gravity(Alignment.CenterHorizontally)
)
}
}
Spacer(Modifier.preferredHeight(10.dp))
Card {
Column(modifier = Modifier.padding(12.dp)) {
accounts.forEach { account ->
AccountRow(
name = account.name,
number = account.number,
amount = account.balance,
color = account.color
)
}
}
}
}