-
Notifications
You must be signed in to change notification settings - Fork 1
FaceID TouchID and friends #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tht7
wants to merge
29
commits into
mlemgroup:master
Choose a base branch
from
tht7:faceId
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
ad6085b
Merge pull request #2 from mormaer/master
tht7 beca6e1
- changed all the NavigationLinks to the new iOS 16 style "value" ori…
b991e4e
- found some more places that need updating to the new value based Na…
d96a32d
- made APIPostView.id truly unique, that way when we update anything …
26dd81c
Merge branch 'mormaer:master' into master-master
tht7 79fd314
Merge remote-tracking branch 'origin/master-master' into open-links-i…
1686eaa
Merge branch 'mormaer:master' into master-master
tht7 24125ad
Merge remote-tracking branch 'origin/master-master' into open-links-i…
d11bdbe
- missed a file during merge
12e68c6
- added a little toast message while resolving the link
8b6895e
- added a new place to save changing account preference
57d68e3
Some bugfixes
b120413
Merge branch 'open-links-in-app' into faceId
01717dc
Merge branch 'mormaer:master' into master-master
tht7 1fa1a5a
Merge remote-tracking branch 'origin/master-master' into faceId
df0efac
The Bio lock screen now uses iOS's thiccMaterial
bf8784e
Merge branch 'mormaer:master' into master-master
tht7 5700dac
created new CachedImageWithNsfwFilter that should be uniform in our a…
a79d696
Merge remote-tracking branch 'origin/better-ish-image-handling' into …
425a2d4
- removed commented test code
1a46ebe
Merge branch 'mormaer:master' into master-master
tht7 038ab8e
Merge remote-tracking branch 'origin/master-master' into better-ish-i…
b71e976
- merged the linter
de5d145
Merge remote-tracking branch 'origin/better-ish-image-handling' into …
c2adc8e
- merged the linter
45ed7d4
Merge branch 'mormaer:master' into master-master
tht7 9d5bd2d
Merge branch 'mormaer:master' into master-master
tht7 be2d0a7
Merge branch 'mormaer:master' into master-master
tht7 cf28b07
Merge remote-tracking branch 'origin/master-master' into faceId
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // | ||
| // View - BioLock.swift | ||
| // Mlem | ||
| // | ||
| // Created by tht7 on 24/06/2023. | ||
| // | ||
|
|
||
| import Foundation | ||
| import SwiftUI | ||
| import LocalAuthentication | ||
|
|
||
|
|
||
| struct HandleAccountSecurity: ViewModifier { | ||
| @EnvironmentObject var accountsTracker: SavedAccountTracker | ||
| @EnvironmentObject var appState: AppState | ||
| let account: SavedAccount? | ||
|
|
||
| @State var context = LAContext() | ||
|
|
||
| func body(content: Content) -> some View { | ||
| if let account = account { | ||
| if accountsTracker.accountPreferences[account.id]?.requiresSecurity == true { | ||
| ZStack { | ||
| content | ||
| if appState.locked { | ||
| // security lock | ||
| Color.clear.background(.thickMaterial) | ||
| VStack { | ||
| Image(systemName: "lock") | ||
| Text("Locked- tap here to unlock") | ||
| } | ||
| .onTapGesture { | ||
| Task(priority: .userInitiated) { | ||
| await unlock() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| content | ||
| } | ||
| } else { | ||
| content | ||
| } | ||
| } | ||
|
|
||
|
|
||
| func unlock() async { | ||
| var error: NSError? | ||
| let reason = "Unlock your account" | ||
| // Check for biometric authentication | ||
| // permissions | ||
| var permissions = context.canEvaluatePolicy( | ||
| .deviceOwnerAuthentication, | ||
| error: &error | ||
| ) | ||
|
|
||
| if permissions { | ||
| do { | ||
| if try await context.evaluatePolicy( | ||
| // .deviceOwnerAuthentication allows | ||
| // biometric or passcode authentication | ||
| .deviceOwnerAuthentication, | ||
| localizedReason: reason | ||
| ) { | ||
| await MainActor.run { | ||
| withAnimation { | ||
| appState.locked = false | ||
| } | ||
| } | ||
| } | ||
| } catch { | ||
| print(String(describing: error)) | ||
| } | ||
| } | ||
| else { | ||
| print(String(describing: error)) | ||
| // Handle permission denied or error | ||
| } | ||
| } | ||
| } | ||
|
|
||
| extension View { | ||
| func handleAccountSecurity(account: SavedAccount?) -> some View { | ||
| modifier(HandleAccountSecurity(account: account)) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // | ||
| // Account Preference.swift | ||
| // Mlem | ||
| // | ||
| // Created by tht7 on 24/06/2023. | ||
| // | ||
|
|
||
| import Foundation | ||
| import SwiftUI | ||
|
|
||
| struct AccountPreference: Decodable, Identifiable, Hashable, Equatable, Encodable { | ||
| var id: Int { | ||
| get { self.hashValue } | ||
| } | ||
|
|
||
| var requiresSecurity: Bool? | ||
|
|
||
| func hash(into hasher: inout Hasher) { | ||
| hasher.combine(requiresSecurity) | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else condition is idempotent, condense these into a single check