Skip to content

Commit

Permalink
Add Not Synced error
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfreeman committed Nov 16, 2022
1 parent 33a88f4 commit 72348b5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ struct WidgetError: View {
Text(text)
.font(.system(size: 14, weight: .medium))
}
.padding(.top, 14)

HStack {
Spacer()
Expand Down
9 changes: 9 additions & 0 deletions Flipper/Packages/UI/Sources/Widget/WidgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@ public struct WidgetView: View {
image: "WidgetFlipperBusy",
isPresented: $viewModel.showAppLocked
)
.padding(.vertical, 14)
} else if viewModel.showCantConnect {
WidgetError(
text: "Can’t Connect to Flipper",
image: "WidgetCantConnect",
isPresented: $viewModel.showCantConnect
)
.padding(.vertical, 14)
} else if viewModel.showNotSynced {
WidgetError(
text: "This Key is Not Synced",
image: "WidgetKeyNotSynced",
isPresented: $viewModel.showNotSynced
)
.padding(.vertical, 14)
} else {
self.keys
}
Expand Down
10 changes: 9 additions & 1 deletion Flipper/Packages/UI/Sources/Widget/WidgetViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class WidgetViewModel: ObservableObject {
@Published public private(set) var keys: [WidgetKey] = []
@Published var isEmulating = false
@Published var showAppLocked = false
@Published var showNotSynced = false
@Published var showCantConnect = false {
didSet {
if showCantConnect == false {
Expand Down Expand Up @@ -129,7 +130,14 @@ public class WidgetViewModel: ObservableObject {
return
}
guard let item = item(for: keys[index]) else {
print("key not found")
logger.error("the key is not found")
resetEmulate()
return
}
guard item.status == .synchronized else {
logger.error("the key is not synced")
showNotSynced = true
resetEmulate()
return
}
emulate.startEmulate(item)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "WidgetKeyNotSynced.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 72348b5

Please sign in to comment.