@@ -3,18 +3,17 @@ package com.jyn.composecalculator.ui
3
3
import androidx.compose.foundation.background
4
4
import androidx.compose.foundation.layout.*
5
5
import androidx.compose.foundation.shape.RoundedCornerShape
6
- import androidx.compose.material3.Button
7
- import androidx.compose.material3.MaterialTheme
8
- import androidx.compose.material3.Surface
9
- import androidx.compose.material3.Text
6
+ import androidx.compose.material3.*
10
7
import androidx.compose.runtime.Composable
11
8
import androidx.compose.ui.Alignment
12
9
import androidx.compose.ui.Modifier
10
+ import androidx.compose.ui.res.painterResource
13
11
import androidx.compose.ui.tooling.preview.Preview
14
12
import androidx.compose.ui.unit.dp
15
13
import androidx.compose.ui.unit.sp
16
14
import androidx.lifecycle.viewmodel.compose.viewModel
17
15
import com.jyn.composecalculator.DateViewModel
16
+ import com.jyn.composecalculator.R
18
17
19
18
/* *
20
19
* 底部按钮
@@ -72,7 +71,6 @@ fun BottomBtnView() {
72
71
73
72
@Composable
74
73
fun ItemBtn (text : String ) {
75
- val modifier = if (text != " =" ) Modifier .aspectRatio(1f ) else Modifier
76
74
val viewModel = viewModel<DateViewModel >()
77
75
78
76
Button (
@@ -89,6 +87,10 @@ fun ItemBtn(text: String) {
89
87
.fillMaxHeight(),
90
88
contentAlignment = Alignment .Center
91
89
) {
90
+ if (text == " D" ) {
91
+ Icon (painter = painterResource(R .drawable.ic_backspace), contentDescription = " " )
92
+ return @Box
93
+ }
92
94
Text (
93
95
text = text,
94
96
fontSize = 30 .sp
0 commit comments