-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ExperimentalFeatures module to SwiftUI
- Loading branch information
Showing
11 changed files
with
147 additions
and
92 deletions.
There are no files selected for viewing
36 changes: 30 additions & 6 deletions
36
UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 7 additions & 1 deletion
8
.../UnstoppableWallet/Modules/Settings/ExperimentalFeatures/ExperimentalFeaturesModule.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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import SwiftUI | ||
import UIKit | ||
|
||
struct ExperimentalFeaturesModule { | ||
|
||
static func viewController() -> UIViewController { | ||
ExperimentalFeaturesViewController() | ||
let view = ExperimentalFeaturesView() | ||
|
||
let viewController = UIHostingController(rootView: view) | ||
viewController.title = "settings.experimental_features.title".localized | ||
|
||
return viewController | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...et/UnstoppableWallet/Modules/Settings/ExperimentalFeatures/ExperimentalFeaturesView.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,24 @@ | ||
import SwiftUI | ||
|
||
struct ExperimentalFeaturesView: View { | ||
|
||
var body: some View { | ||
ScrollableThemeView { | ||
VStack(spacing: .margin24) { | ||
HighlightedTextView(text: "settings.experimental_features.description".localized) | ||
|
||
ListSection { | ||
NavigationRow(destination: { | ||
SimpleActivateModule.bitcoinHodlingView() | ||
}) { | ||
Text("settings.experimental_features.bitcoin_hodling".localized).themeBody() | ||
Image.disclosureIcon | ||
} | ||
} | ||
} | ||
.padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin32, trailing: .margin16)) | ||
} | ||
.navigationBarTitle("settings.experimental_features.title".localized) | ||
} | ||
|
||
} |
77 changes: 0 additions & 77 deletions
77
...ableWallet/Modules/Settings/ExperimentalFeatures/ExperimentalFeaturesViewController.swift
This file was deleted.
Oops, something went wrong.
11 changes: 3 additions & 8 deletions
11
...ppableWallet/UnstoppableWallet/Modules/Settings/SimpleActivate/SimpleActivateModule.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 |
---|---|---|
@@ -1,21 +1,16 @@ | ||
import SwiftUI | ||
import UIKit | ||
|
||
struct SimpleActivateModule { | ||
|
||
static var bitcoinHodlingViewController: UIViewController { | ||
static func bitcoinHodlingView() -> some View { | ||
let viewModel = SimpleActivateViewModel(localStorage: App.shared.localStorage) | ||
|
||
let view = SimpleActivateView( | ||
return SimpleActivateView( | ||
viewModel: viewModel, | ||
title: "settings.bitcoin_hodling.title".localized, | ||
toggleText: "settings.bitcoin_hodling.lock_time".localized, | ||
description: "settings.bitcoin_hodling.description".localized(AppConfig.appName, AppConfig.appName) | ||
) | ||
|
||
let viewController = UIHostingController(rootView: view) | ||
viewController.title = "settings.bitcoin_hodling.title".localized | ||
|
||
return viewController | ||
} | ||
|
||
} |
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
15 changes: 15 additions & 0 deletions
15
UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/Extensions/Image.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,15 @@ | ||
import SwiftUI | ||
|
||
extension Image { | ||
|
||
func themeIcon(color: Color = .themeGray) -> some View { | ||
renderingMode(.template) | ||
.foregroundColor(color) | ||
} | ||
|
||
static var disclosureIcon: some View { | ||
Image("arrow_big_forward_20") | ||
.themeIcon() | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/HighlightedTextView.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,40 @@ | ||
import SwiftUI | ||
|
||
struct HighlightedTextView: View { | ||
private let text: String | ||
private let style: Style | ||
|
||
init(text: String, style: Style = .warning) { | ||
self.text = text | ||
self.style = style | ||
} | ||
|
||
var body: some View { | ||
Text(text) | ||
.padding(EdgeInsets(top: .margin12, leading: .margin16, bottom: .margin12, trailing: .margin16)) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.foregroundColor(.themeBran) | ||
.font(.themeSubhead2) | ||
.background(RoundedRectangle(cornerRadius: .cornerRadius12, style: .continuous).fill(style.color.opacity(0.2))) | ||
.overlay( | ||
RoundedRectangle(cornerRadius: .cornerRadius12, style: .continuous).stroke(style.color, lineWidth: .heightOneDp) | ||
) | ||
} | ||
|
||
} | ||
|
||
extension HighlightedTextView { | ||
|
||
enum Style { | ||
case warning | ||
case alert | ||
|
||
var color: Color { | ||
switch self { | ||
case .warning: return .themeYellow | ||
case .alert: return .themeLucian | ||
} | ||
} | ||
} | ||
|
||
} |
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
15 changes: 15 additions & 0 deletions
15
UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/NavigationRow.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,15 @@ | ||
import SwiftUI | ||
|
||
struct NavigationRow<Content: View, Destination: View>: View { | ||
@ViewBuilder let destination: () -> Destination | ||
@ViewBuilder let content: Content | ||
|
||
var body: some View { | ||
NavigationLink(destination: destination) { | ||
ListRow { | ||
content | ||
} | ||
} | ||
.buttonStyle(RowButton()) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
UnstoppableWallet/UnstoppableWallet/UserInterface/SwiftUI/RowButton.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,10 @@ | ||
import SwiftUI | ||
|
||
struct RowButton: ButtonStyle { | ||
|
||
func makeBody(configuration: Self.Configuration) -> some View { | ||
configuration.label | ||
.background(configuration.isPressed ? Color.themeLawrencePressed : Color.themeLawrence) | ||
} | ||
|
||
} |