Михаил Капелько 9 mesi fa
parent
commit
53c95b4e3a
1 ha cambiato i file con 19 aggiunte e 0 eliminazioni
  1. +19
    -0
      src/App.swift

+ 19
- 0
src/App.swift Vedi File

@@ -5,6 +5,24 @@ import MicX
import SwiftUI
import UIKit

struct Now: View {
@State var refresh = false
let tm = Timer.publish(every: 0.5, on: .current, in: .common).autoconnect()

var now: String {
"Now: " + String(describing: Int(Date().timeIntervalSince1970))
}

var body: some View {
Text(now)
.onReceive(tm) { _ in
self.refresh.toggle()
}
// Магия для обновления себя.
.background(Color.clear.disabled(refresh))
}
}

struct Content: View {
@State private var selectedId = "1"
var ids = ["1", "2", "3", "4"]
@@ -34,6 +52,7 @@ struct Content: View {
MicItem.V(selectedId)
Divider()
.padding()
Now()
List {
ForEach(ids, id: \.self) {
Text("\($0): \(val($0))")


Loading…
Annulla
Salva