fix: ios home widget
This commit is contained in:
@@ -28,7 +28,7 @@ struct Provider: IntentTimelineProvider {
|
|||||||
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
|
func getTimeline(for configuration: ConfigurationIntent, in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
|
||||||
var url = configuration.url
|
var url = configuration.url
|
||||||
|
|
||||||
@Environment(\.widgetFamily) var family: WidgetFamily
|
let family = context.family
|
||||||
if #available(iOSApplicationExtension 16.0, *) {
|
if #available(iOSApplicationExtension 16.0, *) {
|
||||||
if family == .accessoryInline || family == .accessoryRectangular {
|
if family == .accessoryInline || family == .accessoryRectangular {
|
||||||
url = UserDefaults.standard.string(forKey: accessoryKey)
|
url = UserDefaults.standard.string(forKey: accessoryKey)
|
||||||
@@ -57,9 +57,6 @@ struct Provider: IntentTimelineProvider {
|
|||||||
completion(.error(.url("parse url failed")))
|
completion(.error(.url("parse url failed")))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
completion(.loading)
|
|
||||||
|
|
||||||
UserDefaults.standard.set(url.absoluteString, forKey: accessoryKey)
|
|
||||||
|
|
||||||
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
|
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
|
||||||
if error != nil {
|
if error != nil {
|
||||||
@@ -104,7 +101,7 @@ struct StatusWidgetEntryView : View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
switch entry.state {
|
switch entry.state {
|
||||||
case .loading:
|
case .loading:
|
||||||
ProgressView().widgetBackground()
|
Text("Loading").widgetBackground()
|
||||||
case .error(let err):
|
case .error(let err):
|
||||||
switch err {
|
switch err {
|
||||||
case .http(let description):
|
case .http(let description):
|
||||||
@@ -115,12 +112,11 @@ struct StatusWidgetEntryView : View {
|
|||||||
Image(systemName: "arrow.clockwise")
|
Image(systemName: "arrow.clockwise")
|
||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: 10, height: 12.7)
|
.frame(width: 10, height: 12.7)
|
||||||
}
|
}.tint(.gray)
|
||||||
tint(.gray)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.widgetBackground()
|
.widgetBackground()
|
||||||
case .url(let _):
|
case .url(_):
|
||||||
Link("Open wiki ⬅️", destination: helpUrl)
|
Link("Open wiki ⬅️", destination: helpUrl)
|
||||||
.widgetBackground()
|
.widgetBackground()
|
||||||
}
|
}
|
||||||
@@ -156,8 +152,7 @@ struct StatusWidgetEntryView : View {
|
|||||||
Image(systemName: "arrow.clockwise")
|
Image(systemName: "arrow.clockwise")
|
||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: 10, height: 12.7)
|
.frame(width: 10, height: 12.7)
|
||||||
}
|
}.tint(.gray)
|
||||||
tint(.gray)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Text(data.name).font(.system(.title3, design: .monospaced))
|
Text(data.name).font(.system(.title3, design: .monospaced))
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ struct PageView: View {
|
|||||||
Image(systemName: "arrow.clockwise")
|
Image(systemName: "arrow.clockwise")
|
||||||
}.buttonStyle(.plain)
|
}.buttonStyle(.plain)
|
||||||
}
|
}
|
||||||
case .emptyUrl, .invalidUrl:
|
case .url(_):
|
||||||
Link("View help", destination: helpUrl)
|
Link("View help", destination: helpUrl)
|
||||||
}
|
}
|
||||||
case .normal(let status):
|
case .normal(let status):
|
||||||
|
|||||||
Reference in New Issue
Block a user