Михаил Капелько 9 月之前
父節點
當前提交
53c95b4e3a
共有 1 個檔案被更改,包括 19 行新增0 行删除
  1. +19
    -0
      src/App.swift

+ 19
- 0
src/App.swift 查看文件

@@ -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…
取消
儲存