Skip to content

Commit

Permalink
Merge pull request #168 from hugeBlack/main
Browse files Browse the repository at this point in the history
AltStore support & bug fixes
  • Loading branch information
hugeBlack authored Sep 25, 2024
2 parents 76a6643 + e828cf3 commit e5cf20b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 32 deletions.
5 changes: 3 additions & 2 deletions LiveContainerSwiftUI/LCAppBanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ struct LCAppBanner : View {
)
}
if model.uiIsLocked && !model.uiIsHidden {
Text("lc.appBanner.locked".loc).font(.system(size: 8)).bold().padding(2)
.frame(width: 50, height:16)
Image(systemName: "lock.fill")
.font(.system(size: 8))
.frame(width: 16, height:16)
.background(
Capsule().fill(Color("BadgeColor"))
)
Expand Down
2 changes: 1 addition & 1 deletion LiveContainerSwiftUI/LCAppListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ struct LCAppListView : View, LCAppBannerDelegate, LCAppModelDelegate {
}
}.animation(.easeInOut, value: LCUtils.appGroupUserDefault.bool(forKey: "LCStrictHiding"))

if LCUtils.multiLCStatus == 2 {
if sharedModel.multiLCStatus == 2 {
Text("lc.appList.manageInPrimaryTip".loc).foregroundStyle(.gray).padding()
}

Expand Down
29 changes: 22 additions & 7 deletions LiveContainerSwiftUI/LCAppModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,32 @@ class LCAppModel: ObservableObject, Hashable {

}

func toggleLock() async {
if appInfo.isLocked {
func setLocked(newLockState: Bool) async {
// if locked state in appinfo already match with the new state, we just the change
if appInfo.isLocked == newLockState {
return
}

if newLockState {
appInfo.isLocked = true
} else {
// authenticate before cancelling locked state
do {
let result = try await LCUtils.authenticateUser()
if !result {
uiIsLocked = true
return
}
} catch {
uiIsLocked = true
return
}

// auth pass, we need to cancel app's lock and hidden state
appInfo.isLocked = false
uiIsLocked = false

if appInfo.isHidden {
await toggleHidden()
}
} else {
appInfo.isLocked = true
uiIsLocked = true
}
}

Expand Down
16 changes: 1 addition & 15 deletions LiveContainerSwiftUI/LCAppSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,7 @@ struct LCAppSettingsView : View{
Text("lc.appSettings.lockApp".loc)
}
.onChange(of: model.uiIsLocked, perform: { newValue in
Task {
if !newValue {
do {
let result = try await LCUtils.authenticateUser()
if !result {
model.uiIsLocked = true
return
}
} catch {
return
}
}

await model.toggleLock()
}
Task { await model.setLocked(newLockState: newValue) }
})

if model.uiIsLocked {
Expand Down
15 changes: 8 additions & 7 deletions LiveContainerSwiftUI/LCSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,16 @@ struct LCSettingsView: View {
} footer: {
Text("lc.settings.injectLCItselfDesc".loc)
}

Section {
Toggle(isOn: $strictHiding) {
Text("lc.settings.strictHiding".loc)
if sharedModel.isHiddenAppUnlocked {
Section {
Toggle(isOn: $strictHiding) {
Text("lc.settings.strictHiding".loc)
}
} footer: {
Text("lc.settings.strictHidingDesc".loc)
}
} footer: {
Text("lc.settings.strictHidingDesc".loc)
}

Section {
if sharedModel.multiLCStatus != 2 {
Button {
Expand Down

0 comments on commit e5cf20b

Please sign in to comment.