Çözüldü Xcode yazılım hatası nasıl çözülür?

Bu konu çözüldü olarak işaretlenmiştir. Çözülmediğini düşünüyorsanız konuyu rapor edebilirsiniz.

ArdaReis00

Picopat
Katılım
18 Ağustos 2023
Mesajlar
658
Çözümler
2
Yer
Mersin
Daha fazla  
Cinsiyet
Erkek
Arkadaşlar arıyorum ve sürekli bir şey yapamadım bu sorun nasıl çözülür?
 

Dosya Ekleri

  • image.jpg
    image.jpg
    250 KB · Görüntüleme: 33
Çözüm
Text(Text) yazdığınız bölümü Text("Text") olarak değiştirmeyi deneyin.
Eğer olmazsa Text(text) yapmayı deneyin.
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)


}


}
O ikona tıklayıp kodu oraya yapıştırın, lütfen.
Yoksa kodunuz adamakıllı okunamıyor.

1694804077491.png
 


Swift:
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)
    }
}
 

Yeni konular

Geri
Yukarı