-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add UI and information flow for Tor configuration (#112)
- add a new `UserDefaults` to store a boolean saying if Tor is enabled - add a screen to toggle this boolean - add an observer to post any changes to the shared module that will be responsible to forward socket connections through Tor's proxy.
- Loading branch information
Romain Boisselle
authored
Jan 28, 2021
1 parent
b3ada85
commit 665505a
Showing
8 changed files
with
98 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
50 changes: 50 additions & 0 deletions
50
phoenix-ios/phoenix-ios/views/configuration/general/TorConfigurationView.swift
This file contains 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,50 @@ | ||
import SwiftUI | ||
|
||
struct TorConfigurationView: View { | ||
|
||
@State var isTorEnabled = Prefs.shared.isTorEnabled | ||
@State var theme = Prefs.shared.theme | ||
|
||
var body: some View { | ||
Form { | ||
Section(header: TorFormHeader(), content: {}).textCase(nil) | ||
|
||
Toggle(isOn: $isTorEnabled.animation()) { | ||
if isTorEnabled { | ||
Text("Tor is enabled") | ||
} else { | ||
Text("Tor is disabled") | ||
} | ||
}.onChange(of: isTorEnabled) { newValue in | ||
self.toggleTor(newValue) | ||
} | ||
} | ||
.frame(maxWidth: .infinity, maxHeight: .infinity) | ||
.edgesIgnoringSafeArea(.bottom) | ||
.navigationBarTitle("Tor Settings", displayMode: .inline) | ||
} | ||
|
||
struct TorFormHeader: View { | ||
var body: some View { | ||
Text( | ||
"You can improve your privacy by only using Tor when connecting to an Electrum server or" + | ||
" to your Lightning peer. This will slightly slow down your transactions." | ||
) | ||
.font(.body) | ||
.foregroundColor(Color.primary) | ||
.padding(.top, 10) | ||
} | ||
} | ||
|
||
func toggleTor(_ isEnabled: Bool) { | ||
Prefs.shared.isTorEnabled = isEnabled | ||
} | ||
} | ||
|
||
class TorConfigurationView_Previews: PreviewProvider { | ||
|
||
static var previews: some View { | ||
TorConfigurationView() | ||
.previewDevice("iPhone 11") | ||
} | ||
} |
This file contains 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 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 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