ArdaReis00
Picopat
Daha fazla
- Cinsiyet
- Erkek
Text(Text)
yazdığınız bölümü Text("Text")
olarak değiştirmeyi deneyin.Text(text)
yapmayı deneyin.Hocam Xcode'un sorun çözme özelliği vardı, denediniz mi?Arkadaşlar arıyorum ve sürekli bir şey yapamadım bu sorun nasıl çözülür?
Kodun tamamınıArkadaşlar arıyorum ve sürekli bir şey yapamadım bu sorun nasıl çözülür?
O ikona tıklayıp kodu oraya yapıştırın, lütfen.import SwiftUI
struct CalcButtonView: View {
@EnvironmentObject var viewModel: ContentViewModel
let calcButton: CalcButton
let action: (() -> ())?
var wide: Bool {
if let text = calcButton.buttonText {
return text == "0"
}else{
return false
}
}
var backgroundColor: Color {
if let action = calcButton.action,
action == viewModel.action,
viewModel.shouldClear,
viewModel.newAction {
return .white
}else{
return Color(calcButton.color.rawValue)
}
}
var foregroundColor: Color {
if let action = calcButton.action,
action == viewModel.action,
viewModel.shouldClear,
viewModel.newAction {
return Color("Orange")
}else if calcButton.color == .lightGray {
return .black
}else{
return .white
}
}
var body: some View {
Button {
action?()
} label: {
if let text = calcButton.buttonText {
if text == "AC" {
if viewModel.display == "0" {
Text(Text)
}else{
Text("C")
}
}else{
Text(text)
}
}else if let action = calcButton.action {
Image(systemName: action.rawValue)
}
}
.buttonStyle(CalcButtonStyle(size: getSize(),
backgroundColor: backgroundColor,
foregroundColor: foregroundColor,wide: wide))
}
private func getSize() -> CGFloat {
let screenWidth = UIScreen.main.bounds.width
let buttonCount: CGFloat = 4
let spacingCount = buttonCount + 1
return (screenWidth - (spacingCount * Constants.padding)) / buttonCount
}
}
struct CalcButtonView_Previews: PreviewProvider {
static var previews: some View {
CalcButtonView(calcButton: CalcButton(color: .orange, buttonText: "0"), action: nil)
}
}
import SwiftUI
struct CalcButtonView: View {
@EnvironmentObject var viewModel: ContentViewModel
let calcButton: CalcButton
let action: (() -> ())?
var wide: Bool {
if let text = calcButton.buttonText {
return text == "0"
}else{
return false
}
}
var backgroundColor: Color {
if let action = calcButton.action,
action == viewModel.action,
viewModel.shouldClear,
viewModel.newAction {
return .white
}else{
return Color(calcButton.color.rawValue)
}
}
var foregroundColor: Color {
if let action = calcButton.action,
action == viewModel.action,
viewModel.shouldClear,
viewModel.newAction {
return Color("Orange")
}else if calcButton.color == .lightGray {
return .black
}else{
return .white
}
}
var body: some View {
Button {
action?()
} label: {
if let text = calcButton.buttonText {
if text == "AC" {
if viewModel.display == "0" {
Text(Text)
}else{
Text("C")
}
}else{
Text(text)
}
}else if let action = calcButton.action {
Image(systemName: action.rawValue)
}
}
.buttonStyle(CalcButtonStyle(size: getSize(),
backgroundColor: backgroundColor,
foregroundColor: foregroundColor,wide: wide))
}
private func getSize() -> CGFloat {
let screenWidth = UIScreen.main.bounds.width
let buttonCount: CGFloat = 4
let spacingCount = buttonCount + 1
return (screenWidth - (spacingCount * Constants.padding)) / buttonCount
}
}
struct CalcButtonView_Previews: PreviewProvider {
static var previews: some View {
CalcButtonView(calcButton: CalcButton(color: .orange, buttonText: "0"), action: nil)
}
}
Text(Text)
yazdığınız bölümü Text("Text")
olarak değiştirmeyi deneyin.Text(text)
yapmayı deneyin.Text(Text)
yazdığınız bölümüText("Text")
olarak değiştirmeyi deneyin.
Eğer olmazsaText(text)
yapmayı deneyin.
Bu sitenin çalışmasını sağlamak için gerekli çerezleri ve deneyiminizi iyileştirmek için isteğe bağlı çerezleri kullanıyoruz.