Commit 0386184f authored by yqz's avatar yqz

小组件 适配

parent 105c2f12
......@@ -64,6 +64,7 @@ struct SimpleEntry: TimelineEntry {
struct BatteryWidgetEntryView : View {
var entry: Provider.Entry
var body: some View {
if #available(iOSApplicationExtension 17.0, *) {
ZStack {
Color(getwidgetStyle().backgound).ignoresSafeArea()
VStack {
......@@ -83,6 +84,30 @@ struct BatteryWidgetEntryView : View {
}
}.padding(EdgeInsets(top: 16, leading: 10, bottom: 30, trailing: 10))
}
.containerBackground(for: .widget) {
Color(getwidgetStyle().backgound)
}
} else {
ZStack {
Color(getwidgetStyle().backgound).ignoresSafeArea()
VStack {
HStack(alignment: .center) {
Text(getwidgetStyle().lText).frame(maxWidth: .infinity,maxHeight: .infinity,alignment: .topLeading).font(.system(size: 14)).foregroundColor(Color(getwidgetStyle().textColor))
VStack(alignment: .center, spacing: 2) {
Text(String(getwidgetStyle().Angle) + "%" ).frame(maxWidth: .infinity,maxHeight: .infinity,alignment: .topTrailing).font(.system(size: 14)).foregroundColor(Color(getwidgetStyle().textColor))
if entry.widgets / 10 == 1 {
Text("Used").frame(maxWidth: .infinity,alignment: .topTrailing).font(.system(size: 10)).foregroundColor(Color(getwidgetStyle().textColor)).padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 5))
}
}
}
ZStack {
Image(getwidgetStyle().icon)
ArcShape(startAngle: .degrees(-90), endAngle: .degrees(getwidgetStyle().Angle/100.0 * 360.0 - 90.0), clockwise: false)
.stroke(Color(getwidgetStyle().LineColor), style: StrokeStyle(lineWidth: 5, lineCap: .round) )
}
}.padding(EdgeInsets(top: 16, leading: 10, bottom: 30, trailing: 10))
}
}
}
func getwidgetStyle() -> WidgetStyle {
......@@ -150,5 +175,6 @@ struct BatteryWidget: Widget {
BatteryWidgetEntryView(entry: entry)
}.configurationDisplayName("").description("")
.supportedFamilies([.systemSmall , .systemMedium])
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment