Михаил Капелько 10 months ago
parent
commit
53c95b4e3a
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      src/App.swift

+ 19
- 0
src/App.swift View 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…
Cancel
Save