Commit 0386184f authored by yqz's avatar yqz

小组件 适配

parent 105c2f12
...@@ -64,24 +64,49 @@ struct SimpleEntry: TimelineEntry { ...@@ -64,24 +64,49 @@ struct SimpleEntry: TimelineEntry {
struct BatteryWidgetEntryView : View { struct BatteryWidgetEntryView : View {
var entry: Provider.Entry var entry: Provider.Entry
var body: some View { var body: some View {
ZStack { if #available(iOSApplicationExtension 17.0, *) {
Color(getwidgetStyle().backgound).ignoresSafeArea() ZStack {
VStack { Color(getwidgetStyle().backgound).ignoresSafeArea()
HStack(alignment: .center) { VStack {
Text(getwidgetStyle().lText).frame(maxWidth: .infinity,maxHeight: .infinity,alignment: .topLeading).font(.system(size: 14)).foregroundColor(Color(getwidgetStyle().textColor)) HStack(alignment: .center) {
VStack(alignment: .center, spacing: 2) { Text(getwidgetStyle().lText).frame(maxWidth: .infinity,maxHeight: .infinity,alignment: .topLeading).font(.system(size: 14)).foregroundColor(Color(getwidgetStyle().textColor))
Text(String(getwidgetStyle().Angle) + "%" ).frame(maxWidth: .infinity,maxHeight: .infinity,alignment: .topTrailing).font(.system(size: 14)).foregroundColor(Color(getwidgetStyle().textColor)) VStack(alignment: .center, spacing: 2) {
if entry.widgets / 10 == 1 { Text(String(getwidgetStyle().Angle) + "%" ).frame(maxWidth: .infinity,maxHeight: .infinity,alignment: .topTrailing).font(.system(size: 14)).foregroundColor(Color(getwidgetStyle().textColor))
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)) 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 {
ZStack { Image(getwidgetStyle().icon)
Image(getwidgetStyle().icon) ArcShape(startAngle: .degrees(-90), endAngle: .degrees(getwidgetStyle().Angle/100.0 * 360.0 - 90.0), clockwise: false)
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) )
.stroke(Color(getwidgetStyle().LineColor), style: StrokeStyle(lineWidth: 5, lineCap: .round) ) }
} }.padding(EdgeInsets(top: 16, leading: 10, bottom: 30, trailing: 10))
}.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))
}
} }
} }
...@@ -150,5 +175,6 @@ struct BatteryWidget: Widget { ...@@ -150,5 +175,6 @@ struct BatteryWidget: Widget {
BatteryWidgetEntryView(entry: entry) BatteryWidgetEntryView(entry: entry)
}.configurationDisplayName("").description("") }.configurationDisplayName("").description("")
.supportedFamilies([.systemSmall , .systemMedium]) .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