WIP: PN mode selection screen
This commit is contained in:
parent
1adca8bbb1
commit
1421992e97
|
@ -123,6 +123,7 @@
|
|||
7B81682C28B72F480069F315 /* PendingChange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B81682B28B72F480069F315 /* PendingChange.swift */; };
|
||||
7B87EF422A8D9840002A0E8F /* DisplayNameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */; };
|
||||
7B87EF442A8DA720002A0E8F /* SessionTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF432A8DA720002A0E8F /* SessionTextField.swift */; };
|
||||
7B87EF462A8DDA8E002A0E8F /* PNModeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */; };
|
||||
7B8914772A7CAAE200A4C627 /* SessionHostingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8914762A7CAAE200A4C627 /* SessionHostingViewController.swift */; };
|
||||
7B8C44C528B49DDA00FBE25F /* NewConversationVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8C44C428B49DDA00FBE25F /* NewConversationVC.swift */; };
|
||||
7B8D5FC428332600008324D9 /* VisibleMessage+Reaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B8D5FC328332600008324D9 /* VisibleMessage+Reaction.swift */; };
|
||||
|
@ -1239,6 +1240,7 @@
|
|||
7B81682B28B72F480069F315 /* PendingChange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PendingChange.swift; sourceTree = "<group>"; };
|
||||
7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayNameView.swift; sourceTree = "<group>"; };
|
||||
7B87EF432A8DA720002A0E8F /* SessionTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionTextField.swift; sourceTree = "<group>"; };
|
||||
7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNModeView.swift; sourceTree = "<group>"; };
|
||||
7B8914762A7CAAE200A4C627 /* SessionHostingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionHostingViewController.swift; sourceTree = "<group>"; };
|
||||
7B8C44C428B49DDA00FBE25F /* NewConversationVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationVC.swift; sourceTree = "<group>"; };
|
||||
7B8D5FC328332600008324D9 /* VisibleMessage+Reaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VisibleMessage+Reaction.swift"; sourceTree = "<group>"; };
|
||||
|
@ -3005,6 +3007,7 @@
|
|||
B8D0A26825E4A2C200C1835E /* Onboarding.swift */,
|
||||
7BDE2A972A8B122900AE4393 /* LandingView.swift */,
|
||||
7B87EF412A8D9840002A0E8F /* DisplayNameView.swift */,
|
||||
7B87EF452A8DDA8E002A0E8F /* PNModeView.swift */,
|
||||
);
|
||||
path = Onboarding;
|
||||
sourceTree = "<group>";
|
||||
|
@ -6149,6 +6152,7 @@
|
|||
B82B4090239DD75000A248E7 /* RestoreVC.swift in Sources */,
|
||||
3488F9362191CC4000E524CC /* MediaView.swift in Sources */,
|
||||
B8569AC325CB5D2900DBA3DB /* ConversationVC+Interaction.swift in Sources */,
|
||||
7B87EF462A8DDA8E002A0E8F /* PNModeView.swift in Sources */,
|
||||
3496955C219B605E00DCFE74 /* ImagePickerController.swift in Sources */,
|
||||
C31D1DE32521718E005D4DA8 /* UserSelectionVC.swift in Sources */,
|
||||
34A6C28021E503E700B5B12E /* OWSImagePickerController.swift in Sources */,
|
||||
|
|
|
@ -118,6 +118,9 @@ struct DisplayNameView: View {
|
|||
}
|
||||
|
||||
// Need to get the PN mode if registering
|
||||
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: PNModeView(flow: flow))
|
||||
viewController.setUpNavBarSessionIcon()
|
||||
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,203 @@
|
|||
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
||||
|
||||
import SwiftUI
|
||||
import Combine
|
||||
import SessionUIKit
|
||||
import SessionMessagingKit
|
||||
import SessionSnodeKit
|
||||
import SignalUtilitiesKit
|
||||
import SessionUtilitiesKit
|
||||
|
||||
enum PNMode {
|
||||
case fast
|
||||
case slow
|
||||
}
|
||||
|
||||
struct PNModeView: View {
|
||||
@EnvironmentObject var host: HostWrapper
|
||||
|
||||
@State private var currentSelection: PNMode = .fast
|
||||
|
||||
private let flow: Onboarding.Flow
|
||||
|
||||
public init(flow: Onboarding.Flow) {
|
||||
self.flow = flow
|
||||
}
|
||||
|
||||
let options: [PNOptionView.Info] = [
|
||||
PNOptionView.Info(
|
||||
mode: .fast,
|
||||
title: "fast_mode".localized(),
|
||||
explanation: "fast_mode_explanation".localized(),
|
||||
isRecommended: true
|
||||
),
|
||||
PNOptionView.Info(
|
||||
mode: .slow,
|
||||
title: "slow_mode".localized(),
|
||||
explanation: "slow_mode_explanation".localized(),
|
||||
isRecommended: false
|
||||
)
|
||||
]
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
ZStack(alignment: .center) {
|
||||
if #available(iOS 14.0, *) {
|
||||
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea()
|
||||
} else {
|
||||
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary)
|
||||
}
|
||||
|
||||
VStack(
|
||||
alignment: .leading,
|
||||
spacing: Values.mediumSpacing
|
||||
) {
|
||||
Spacer()
|
||||
|
||||
Text("vc_pn_mode_title".localized())
|
||||
.bold()
|
||||
.font(.system(size: Values.veryLargeFontSize))
|
||||
.foregroundColor(themeColor: .textPrimary)
|
||||
.padding(.vertical, Values.mediumSpacing)
|
||||
|
||||
VStack(
|
||||
alignment: .leading,
|
||||
spacing: Values.mediumSpacing)
|
||||
{
|
||||
ForEach(
|
||||
0...(options.count - 1),
|
||||
id: \.self
|
||||
) { index in
|
||||
PNOptionView(
|
||||
currentSelection: $currentSelection,
|
||||
info: options[index]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.padding(.horizontal, Values.veryLargeSpacing)
|
||||
.padding(.bottom, Values.massiveSpacing + Values.largeButtonHeight)
|
||||
|
||||
VStack() {
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
register()
|
||||
} label: {
|
||||
Text("continue_2".localized())
|
||||
.bold()
|
||||
.font(.system(size: Values.smallFontSize))
|
||||
.foregroundColor(themeColor: .sessionButton_text)
|
||||
.frame(
|
||||
maxWidth: .infinity,
|
||||
maxHeight: Values.largeButtonHeight,
|
||||
alignment: .center
|
||||
)
|
||||
.overlay(
|
||||
Capsule()
|
||||
.stroke(themeColor: .sessionButton_border)
|
||||
)
|
||||
}
|
||||
.padding(.horizontal, Values.massiveSpacing)
|
||||
}
|
||||
.padding(.vertical, Values.mediumSpacing)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func register() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
struct PNOptionView: View {
|
||||
|
||||
struct Info {
|
||||
let mode: PNMode
|
||||
let title: String
|
||||
let explanation: String
|
||||
let isRecommended: Bool
|
||||
}
|
||||
|
||||
@Binding var currentSelection: PNMode
|
||||
|
||||
let info: Info
|
||||
|
||||
static let cornerRadius: CGFloat = 8
|
||||
static let radioBorderSize: CGFloat = 22
|
||||
static let radioSelectionSize: CGFloat = 17
|
||||
|
||||
var body: some View {
|
||||
HStack(
|
||||
spacing: Values.largeSpacing
|
||||
) {
|
||||
VStack(
|
||||
alignment: .leading,
|
||||
spacing: Values.smallSpacing
|
||||
) {
|
||||
Text(info.title)
|
||||
.bold()
|
||||
.font(.system(size: Values.mediumFontSize))
|
||||
.foregroundColor(themeColor: .textPrimary)
|
||||
|
||||
Text(info.explanation)
|
||||
.font(.system(size: Values.verySmallFontSize))
|
||||
.foregroundColor(themeColor: .textPrimary)
|
||||
.frame(
|
||||
maxWidth: .infinity,
|
||||
alignment: .leading
|
||||
)
|
||||
|
||||
if info.isRecommended {
|
||||
Text("vc_pn_mode_recommended_option_tag".localized())
|
||||
.bold()
|
||||
.font(.system(size: Values.smallFontSize))
|
||||
.foregroundColor(themeColor: .primary)
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.all, Values.mediumSpacing)
|
||||
.overlay(
|
||||
RoundedRectangle(
|
||||
cornerSize: CGSize(
|
||||
width: Self.cornerRadius,
|
||||
height: Self.cornerRadius
|
||||
)
|
||||
)
|
||||
.stroke(themeColor: .borderSeparator)
|
||||
)
|
||||
|
||||
ZStack(alignment: .center) {
|
||||
Circle()
|
||||
.stroke(themeColor: .textPrimary)
|
||||
.frame(
|
||||
width: Self.radioBorderSize,
|
||||
height: Self.radioBorderSize
|
||||
)
|
||||
|
||||
if currentSelection == info.mode {
|
||||
Circle()
|
||||
.fill(themeColor: .primary)
|
||||
.frame(
|
||||
width: Self.radioSelectionSize,
|
||||
height: Self.radioSelectionSize
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(
|
||||
maxWidth: .infinity
|
||||
)
|
||||
.onTapGesture {
|
||||
currentSelection = info.mode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct PNModeView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
PNModeView(flow: .register)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue