Fixed blinking connection status in home
@@ -24,7 +24,7 @@ struct HomeView : MVIView {
ZStack {
VStack() {
HStack {
- ConnectionStatus(status: model.connections.global, show: $showConnections)
+ ConnectionStatus(status: model.connections.global, showPopup: $showConnections)
Spacer()
}
.padding()
@@ -80,15 +80,15 @@ struct HomeView : MVIView {
struct ConnectionStatus : View {
let status: Eclair_kmpConnection
- @Binding var show: Bool
+ @Binding var showPopup: Bool
- @State var started = false
@State var dimStatus = false
var body: some View {
+ Group {
Button {
withAnimation(.easeInOut(duration: 0.3)) {
- show = true
+ showPopup = true
}
} label: {
HStack {
@@ -109,9 +109,8 @@ struct HomeView : MVIView {
)
.opacity(dimStatus ? 0.2 : 1.0)
.isHidden(status == Eclair_kmpConnection.established)
+ }
.onAppear {
- if (!started) {
- started = true
DispatchQueue.main.async {
withAnimation(Animation.linear(duration: 1.0).repeatForever()) {
self.dimStatus.toggle()
@@ -120,7 +119,6 @@ struct HomeView : MVIView {
}
}
}
- }
struct ConnectionPopup : View {
let connections: Connections
@@ -278,8 +276,8 @@ class HomeView_Previews : PreviewProvider {
)
static var previews: some View {
-// mockView(HomeView()) { $0.homeModel = mockModel }
- appView(HomeView())
+ mockView(HomeView()) { $0.homeModel = mockModel }
+// appView(HomeView())
.previewDevice("iPhone 11")
}
