Skip to content

Commit 6e4ad19

Browse files
author
leminlimez
committed
added LS footnote changer
1 parent 3279857 commit 6e4ad19

File tree

10 files changed

+160
-0
lines changed

10 files changed

+160
-0
lines changed

.DS_Store

2 KB
Binary file not shown.
24 Bytes
Binary file not shown.
16 Bytes
Binary file not shown.

TrollTools.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
6F63906B294B957900BA22D4 /* LSFootnoteChangerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F63906A294B957900BA22D4 /* LSFootnoteChangerView.swift */; };
1011
6FDA067D2935AA52003CE14A /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 6FDA067C2935AA52003CE14A /* ZIPFoundation */; };
1112
CE141B372903E73F00AB48A7 /* CardChangerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE141B362903E73F00AB48A7 /* CardChangerView.swift */; };
1213
CE141B3A2903F20800AB48A7 /* ThemesSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE141B392903F20800AB48A7 /* ThemesSettingsView.swift */; };
@@ -53,6 +54,7 @@
5354
/* End PBXBuildFile section */
5455

5556
/* Begin PBXFileReference section */
57+
6F63906A294B957900BA22D4 /* LSFootnoteChangerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LSFootnoteChangerView.swift; sourceTree = "<group>"; };
5658
CE141B362903E73F00AB48A7 /* CardChangerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardChangerView.swift; sourceTree = "<group>"; };
5759
CE141B392903F20800AB48A7 /* ThemesSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemesSettingsView.swift; sourceTree = "<group>"; };
5860
CE141B3B2903F22F00AB48A7 /* ThemeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeView.swift; sourceTree = "<group>"; };
@@ -250,6 +252,7 @@
250252
CE7975B0291C4533007A38E7 /* LockscreenRespringView.swift */,
251253
CEF56C3E291C605600DDEBFD /* CalculatorErrorView.swift */,
252254
CEF56C5329215AA900DDEBFD /* CarrierNameChangerView.swift */,
255+
6F63906A294B957900BA22D4 /* LSFootnoteChangerView.swift */,
253256
);
254257
path = Tools;
255258
sourceTree = "<group>";
@@ -392,6 +395,7 @@
392395
CE7975A5291B1E0C007A38E7 /* ToolsView.swift in Sources */,
393396
CE2BF8242902E07F00AD10BE /* Extensions.swift in Sources */,
394397
CE141B5A290460AE00AB48A7 /* WebclipsThemeManager.swift in Sources */,
398+
6F63906B294B957900BA22D4 /* LSFootnoteChangerView.swift in Sources */,
395399
CEF56C3F291C605600DDEBFD /* CalculatorErrorView.swift in Sources */,
396400
CE7975A7291B2A4B007A38E7 /* GesturesView.swift in Sources */,
397401
CE76386D290AED160099C6F0 /* ProblemReporter.swift in Sources */,

TrollTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
6 KB
Binary file not shown.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
//
2+
// LSFootnoteChangerView.swift
3+
// TrollTools
4+
//
5+
// Created by LeminLimez on 12/15/22.
6+
//
7+
8+
import SwiftUI
9+
10+
struct LSFootnoteChangerView: View {
11+
@State var footnoteText = ""
12+
@State var footnoteOffset: CGFloat = .zero
13+
@State var footnoteSize: [CGFloat] = [.zero, .zero]
14+
15+
var sharedDeviceConfigPath = "/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles/Library/ConfigurationProfiles"
16+
17+
var body: some View {
18+
ZStack {
19+
VStack {
20+
Spacer()
21+
ZStack(alignment: .center) {
22+
Image("lockscreen")
23+
.resizable()
24+
.aspectRatio(contentMode: .fit)
25+
.frame(maxWidth: .infinity)
26+
.padding(.bottom)
27+
.background(GeometryReader { (geometry) -> Color in
28+
DispatchQueue.main.async {
29+
// set the footnote textbox size
30+
footnoteSize[0] = geometry.size.width/3
31+
footnoteSize[1] = geometry.size.height/25
32+
33+
// set the footnote textbox offset
34+
footnoteOffset = -geometry.size.height/2 + (870/990) * geometry.size.height + footnoteSize[1]/2
35+
}
36+
return .clear
37+
})
38+
TextField("Footnote", text: $footnoteText)
39+
.foregroundColor(.white)
40+
.offset(x: 0, y: footnoteOffset)
41+
.frame(width: footnoteSize[0], height: footnoteSize[1], alignment: .center)
42+
.multilineTextAlignment(.center)
43+
}
44+
}
45+
}
46+
//.ignoresSafeArea(.keyboard, edges: .bottom)
47+
.toolbar {
48+
ToolbarItem(placement: .navigationBarTrailing) {
49+
Button(action: {
50+
do {
51+
let url = URL(fileURLWithPath: sharedDeviceConfigPath + "/SharedDeviceConfiguration.plist")
52+
53+
var plistData: Data
54+
if !FileManager.default.fileExists(atPath: url.path) {
55+
plistData = try PropertyListSerialization.data(fromPropertyList: ["LockScreenFootnote": footnoteText], format: .xml, options: 0)
56+
} else {
57+
guard let data = try? Data(contentsOf: url), var plist = try PropertyListSerialization.propertyList(from: data, format: nil) as? [String:Any] else { throw "Couldn't read SharedDeviceConfiguration.plist" }
58+
plist["LockScreenFootnote"] = footnoteText
59+
60+
// Save plist
61+
plistData = try PropertyListSerialization.data(fromPropertyList: plist, format: .xml, options: 0)
62+
UserDefaults.standard.set(footnoteText, forKey: "LSFootnoteText")
63+
}
64+
65+
// write to file
66+
try RootHelper.writeStr(String(decoding: plistData, as: UTF8.self), to: url)
67+
} catch {
68+
UIApplication.shared.alert(body: "\(error)")
69+
}
70+
}) {
71+
Image(systemName: "checkmark")
72+
}
73+
}
74+
}
75+
.onAppear {
76+
footnoteText = UserDefaults.standard.string(forKey: "LSFootnoteText") ?? ""
77+
}
78+
.navigationTitle("Lock Screen Footnote Changer")
79+
}
80+
}
81+
82+
struct LSFootnoteChangerView_Previews: PreviewProvider {
83+
static var previews: some View {
84+
LSFootnoteChangerView()
85+
}
86+
}

TrollTools/Views/Tools/ToolsView.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ struct ToolsView: View {
9999
.padding(.horizontal, 8)
100100
}
101101
}
102+
NavigationLink(destination: LSFootnoteChangerView()) {
103+
HStack {
104+
Image(systemName: "platter.filled.bottom.and.arrow.down.iphone")
105+
.resizable()
106+
.aspectRatio(contentMode: .fit)
107+
.frame(width: 24, height: 24)
108+
.foregroundColor(.blue)
109+
Text("Lock Screen Footnote")
110+
.padding(.horizontal, 8)
111+
}
112+
}
102113
} header: {
103114
Text("General")
104115
}

0 commit comments

Comments
 (0)