Servus,
Ich habe das Problem, dass ich den Titel für die Seite nicht färben kann.
Ich habs versucht anzupassen, es soll nicht Schwarz sein sondern in diesem Gold/Beige Ton..
Könntet ihr mir dabei kurz helfen?
Viele Grüße
Alles anzeigen
Ich habe das Problem, dass ich den Titel für die Seite nicht färben kann.
Ich habs versucht anzupassen, es soll nicht Schwarz sein sondern in diesem Gold/Beige Ton..
Könntet ihr mir dabei kurz helfen?
Viele Grüße
Python-Quellcode
- import SwiftUI
- struct DhikrView: View {
- @State private var counters: [Counter] = [Counter(name: "test", count: 0)]
- @State private var showingAddCounter = false
- var body: some View {
- NavigationView {
- ZStack {
- Color(hex: "#10231d").edgesIgnoringSafeArea(.all)
- VStack {
- ScrollView {
- ForEach($counters) { $counter in
- CounterView(counter: $counter, onDelete: {
- if let index = counters.firstIndex(where: { $0.id == counter.id }) {
- counters.remove(at: index)
- }
- })
- .padding(.bottom)
- }
- }
- .frame(maxHeight: 600)
- .scrollIndicators(.never) // Hide the scroll indicators
- }
- .navigationBarTitleDisplayMode(.inline)
- .toolbar {
- ToolbarItem(placement: .navigationBarTrailing) {
- Button(action: {
- showingAddCounter.toggle()
- }) {
- Image(systemName: "plus")
- .foregroundColor(Color(hex: "#bcad82"))
- }
- }
- }
- .sheet(isPresented: $showingAddCounter) {
- AddCounterView(counters: $counters)
- }
- }
- .navigationTitle("Dhikr")
- .foregroundColor(Color(hex: "#bcad82")) // Set title color to gold
- .font(.headline)
- }
- }
- }
- struct Counter: Identifiable {
- let id = UUID()
- var name: String
- var count: Int = 0
- }
- struct CounterView: View {
- @Binding var counter: Counter
- var onDelete: () -> Void
- var body: some View {
- VStack {
- Text(counter.name)
- .font(.headline)
- .foregroundColor(Color(hex: "#bcad82"))
- Button(action: {
- counter.count += 1
- let generator = UIImpactFeedbackGenerator(style: .medium)
- generator.impactOccurred()
- withAnimation(.easeInOut) {
- counter.count += 0
- }
- }) {
- ZStack {
- Circle()
- .fill(Color(hex: "#bcad82"))
- .frame(width: 110, height: 110)
- Text("\(counter.count)")
- .font(.largeTitle)
- .foregroundColor(Color(hex: "#10231d"))
- }
- }
- .contextMenu {
- Button(role: .destructive) {
- onDelete()
- } label: {
- Label("Löschen", systemImage: "trash")
- }
- Button(action: {
- counter.count = 0
- }) {
- Label("Zurücksetzen", systemImage: "arrow.counterclockwise")
- }
- }
- .onLongPressGesture {
- counter.count = 0
- }
- }
- .padding()
- .background(Color(hex: "#10231d"))
- .cornerRadius(8)
- }
- }
- struct AddCounterView: View {
- @Environment(\.presentationMode) var presentationMode
- @Binding var counters: [Counter]
- @State private var name = ""
- var body: some View {
- NavigationView {
- Form {
- Section(header: Text("Name")) {
- TextField("Vergebe einen Namen", text: $name)
- }
- }
- .navigationBarTitle("Dhikr", displayMode: .inline)
- .toolbar {
- ToolbarItem(placement: .navigationBarLeading) {
- Button("Abbrechen") {
- presentationMode.wrappedValue.dismiss()
- }
- }
- ToolbarItem(placement: .navigationBarTrailing) {
- Button("Speichern") {
- let newCounter = Counter(name: name)
- counters.append(newCounter)
- presentationMode.wrappedValue.dismiss()
- }
- }
- }
- }
- }
- }
- #Preview {
- DhikrView()
- }