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
d0038a1f
Commit
d0038a1f
authored
Apr 03, 2025
by
yqz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
widget
parent
d7b597a1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
389 additions
and
0 deletions
+389
-0
AppIntent.swift
BatteryWidget/AppIntent.swift
+19
-0
Contents.json
...Widget/Assets.xcassets/AccentColor.colorset/Contents.json
+11
-0
Contents.json
...ryWidget/Assets.xcassets/AppIcon.appiconset/Contents.json
+35
-0
Contents.json
BatteryWidget/Assets.xcassets/Contents.json
+6
-0
Contents.json
...t/Assets.xcassets/WidgetBackground.colorset/Contents.json
+11
-0
BatteryWidget.swift
BatteryWidget/BatteryWidget.swift
+83
-0
BatteryWidgetBundle.swift
BatteryWidget/BatteryWidgetBundle.swift
+16
-0
Info.plist
BatteryWidget/Info.plist
+11
-0
BatteryWidgetExtension.entitlements
BatteryWidgetExtension.entitlements
+5
-0
project.pbxproj
PhoneManager.xcodeproj/project.pbxproj
+187
-0
PhoneManager.entitlements
PhoneManager/PhoneManager.entitlements
+5
-0
No files found.
BatteryWidget/AppIntent.swift
0 → 100644
View file @
d0038a1f
//
// AppIntent.swift
// BatteryWidget
//
// Created by edy on 2025/4/2.
//
import
WidgetKit
import
AppIntents
//struct ConfigurationAppIntent: WidgetConfigurationIntent {
// static var title: LocalizedStringResource { "Configuration" }
// static var description: IntentDescription { "This is an example widget." }
//
// // An example configurable parameter.
// @Parameter(title: "Favorite Emoji", default: "😃")
// var favoriteEmoji: String
//}
BatteryWidget/Assets.xcassets/AccentColor.colorset/Contents.json
0 → 100644
View file @
d0038a1f
{
"colors"
:
[
{
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
BatteryWidget/Assets.xcassets/AppIcon.appiconset/Contents.json
0 → 100644
View file @
d0038a1f
{
"images"
:
[
{
"idiom"
:
"universal"
,
"platform"
:
"ios"
,
"size"
:
"1024x1024"
},
{
"appearances"
:
[
{
"appearance"
:
"luminosity"
,
"value"
:
"dark"
}
],
"idiom"
:
"universal"
,
"platform"
:
"ios"
,
"size"
:
"1024x1024"
},
{
"appearances"
:
[
{
"appearance"
:
"luminosity"
,
"value"
:
"tinted"
}
],
"idiom"
:
"universal"
,
"platform"
:
"ios"
,
"size"
:
"1024x1024"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
BatteryWidget/Assets.xcassets/Contents.json
0 → 100644
View file @
d0038a1f
{
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
BatteryWidget/Assets.xcassets/WidgetBackground.colorset/Contents.json
0 → 100644
View file @
d0038a1f
{
"colors"
:
[
{
"idiom"
:
"universal"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
BatteryWidget/BatteryWidget.swift
0 → 100644
View file @
d0038a1f
//
// BatteryWidget.swift
// BatteryWidget
//
// Created by edy on 2025/4/2.
//
import
WidgetKit
import
SwiftUI
struct
Provider
:
TimelineProvider
{
func
placeholder
(
in
context
:
Context
)
->
SimpleEntry
{
SimpleEntry
(
date
:
Date
(),
type
:
0
,
style
:
0
,
battery
:
0
,
storage
:
0
)
}
func
getSnapshot
(
in
context
:
Context
,
completion
:
@escaping
(
SimpleEntry
)
->
Void
)
{
let
entry
=
loadSharedData
()
completion
(
entry
)
}
func
getTimeline
(
in
context
:
Context
,
completion
:
@escaping
(
Timeline
<
SimpleEntry
>
)
->
Void
)
{
let
entry
=
loadSharedData
()
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
after
(
Date
()
.
addingTimeInterval
(
60
)))
// 每小时更新
completion
(
timeline
)
}
private
func
loadSharedData
()
->
SimpleEntry
{
guard
let
sharedDefaults
=
UserDefaults
(
suiteName
:
"group.com.app.phonemanager"
),
let
data
:[
String
:
Int
]
=
sharedDefaults
.
object
(
forKey
:
"widgetSharedData"
)
as?
[
String
:
Int
]
else
{
return
SimpleEntry
(
date
:
Date
(),
type
:
0
,
style
:
0
,
battery
:
0
,
storage
:
0
)
}
return
SimpleEntry
(
date
:
Date
(),
type
:
0
,
style
:
0
,
battery
:
0
,
storage
:
0
)
}
}
struct
SimpleEntry
:
TimelineEntry
{
let
date
:
Date
let
type
:
Int
let
style
:
Int
let
battery
:
Int
let
storage
:
Int
}
struct
BatteryWidgetEntryView
:
View
{
var
entry
:
Provider
.
Entry
var
body
:
some
View
{
VStack
{
Text
(
"Time:"
)
Text
(
entry
.
date
,
style
:
.
time
)
}
}
}
struct
BatteryWidget
:
Widget
{
let
kind
:
String
=
"BatteryWidget"
var
body
:
some
WidgetConfiguration
{
StaticConfiguration
(
kind
:
kind
,
provider
:
Provider
())
{
entry
in
BatteryWidgetEntryView
(
entry
:
entry
)
}
}
}
//extension ConfigurationAppIntent {
// fileprivate static var smiley: ConfigurationAppIntent {
// let intent = ConfigurationAppIntent()
// intent.favoriteEmoji = "😀"
// return intent
// }
//
// fileprivate static var starEyes: ConfigurationAppIntent {
// let intent = ConfigurationAppIntent()
// intent.favoriteEmoji = "🤩"
// return intent
// }
//}
//#Preview(as: .systemSmall) {
// BatteryWidget()
//} timeline: {
// SimpleEntry(date: .now, type: 0, style: 0, battery: 24, storage: 39)
//}
BatteryWidget/BatteryWidgetBundle.swift
0 → 100644
View file @
d0038a1f
//
// BatteryWidgetBundle.swift
// BatteryWidget
//
// Created by edy on 2025/4/2.
//
import
WidgetKit
import
SwiftUI
@main
struct
BatteryWidgetBundle
:
WidgetBundle
{
var
body
:
some
Widget
{
BatteryWidget
()
}
}
BatteryWidget/Info.plist
0 → 100644
View file @
d0038a1f
<
?xml
v
e
rsion="
1
.
0
"
e
n
c
o
d
ing="UT
F
-
8
"?
>
<
!
D
O
C
TYP
E
plist
PU
B
LI
C
"-//
A
ppl
e
//
D
T
D
PLIST
1
.
0
//
E
N"
"http://www.
a
ppl
e
.
c
om/
D
T
D
s/Prop
e
rtyList-
1
.
0
.
d
t
d
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
k
e
y
>
NSExtension
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
NSExtensionPointIdentifier
<
/k
e
y
>
<
string
>
com.apple.widgetkit-extension
<
/string
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
/plist
>
BatteryWidgetExtension.entitlements
0 → 100644
View file @
d0038a1f
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict/>
</plist>
PhoneManager.xcodeproj/project.pbxproj
View file @
d0038a1f
This diff is collapsed.
Click to expand it.
PhoneManager/PhoneManager.entitlements
0 → 100644
View file @
d0038a1f
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict/>
</plist>
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