Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PhoneManager
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yang
PhoneManager
Commits
0386184f
Commit
0386184f
authored
Apr 10, 2025
by
yqz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小组件 适配
parent
105c2f12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
16 deletions
+42
-16
widget.swift
widget/widget.swift
+42
-16
No files found.
widget/widget.swift
View file @
0386184f
...
@@ -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
])
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment