refactor and improvements on landing view

This commit is contained in:
Ryan Zhao 2023-08-17 14:14:07 +10:00
parent e414f17a4d
commit 6cd8326904
6 changed files with 89 additions and 29 deletions

View File

@ -475,7 +475,7 @@ final class MessageInfoViewController: SessionHostingViewController<MessageInfoV
)
super.init(rootView: messageInfoView)
rootView.dismiss = dismiss
rootView.content.dismiss = dismiss
}
@MainActor required dynamic init?(coder aDecoder: NSCoder) {

View File

@ -0,0 +1,15 @@
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import SwiftUI
struct DisplayNameView: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
struct DisplayNameView_Previews: PreviewProvider {
static var previews: some View {
DisplayNameView()
}
}

View File

@ -1,12 +1,15 @@
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import SwiftUI
import UIKit
import SessionUIKit
struct LandingView: View {
@EnvironmentObject var host: HostWrapper
var body: some View {
NavigationView {
ZStack (alignment: .topLeading) {
ZStack(alignment: .center) {
if #available(iOS 14.0, *) {
ThemeManager.currentTheme.colorSwiftUI(for: .backgroundPrimary).ignoresSafeArea()
} else {
@ -15,9 +18,9 @@ struct LandingView: View {
VStack(
alignment: .center,
spacing: 16
spacing: Values.mediumSpacing
) {
Spacer(minLength: Values.massiveSpacing)
Spacer()
Text("onboarding_landing_title".localized())
.bold()
@ -27,10 +30,19 @@ struct LandingView: View {
FakeChat()
Spacer(minLength: Values.massiveSpacing)
Spacer()
}
.padding(.vertical, Values.mediumSpacing)
.padding(.bottom, Values.massiveSpacing + 3 * Values.largeButtonHeight)
VStack(
alignment: .center,
spacing: Values.mediumSpacing)
{
Spacer()
Button {
register()
} label: {
Text("onboarding_landing_register_button_title".localized())
.bold()
@ -47,7 +59,7 @@ struct LandingView: View {
.padding(.horizontal, Values.massiveSpacing)
Button {
restore()
} label: {
Text("onboarding_landing_restore_button_title".localized())
.bold()
@ -84,10 +96,19 @@ struct LandingView: View {
}
.padding(.horizontal, Values.massiveSpacing)
}
.padding(.vertical, Values.mediumSpacing)
}
}
}
private func register() {
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: DisplayNameView(flow: .register))
viewController.setUpNavBarSessionIcon()
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
}
private func restore() {
}
}
struct ChatBubble: View {
@ -118,28 +139,23 @@ struct FakeChat: View {
]
var body: some View {
ScrollView(
.vertical,
showsIndicators: false
VStack(
alignment: .leading,
spacing: 18
) {
VStack(
alignment: .leading,
spacing: 18
) {
ForEach(
0...(chatBubbles.count - 1),
id: \.self
) { index in
let chatBubble: ChatBubble = chatBubbles[index]
chatBubble
.frame(
maxWidth: .infinity,
alignment: chatBubble.outgoing ? .trailing : .leading
)
}
ForEach(
0...(chatBubbles.count - 1),
id: \.self
) { index in
let chatBubble: ChatBubble = chatBubbles[index]
chatBubble
.frame(
maxWidth: .infinity,
alignment: chatBubble.outgoing ? .trailing : .leading
)
}
.padding(.horizontal, 36)
}
.padding(.horizontal, 36)
}
}

View File

@ -3,7 +3,11 @@
import SwiftUI
import SessionUIKit
public class SessionHostingViewController<Content>: UIHostingController<Content> where Content : View {
public class HostWrapper: ObservableObject {
public weak var controller: UIViewController?
}
public class SessionHostingViewController<Content>: UIHostingController<ModifiedContent<Content,SwiftUI._EnvironmentKeyWritingModifier<HostWrapper?>>> where Content : View {
public override var preferredStatusBarStyle: UIStatusBarStyle {
return ThemeManager.currentTheme.statusBarStyle
}
@ -28,6 +32,17 @@ public class SessionHostingViewController<Content>: UIHostingController<Content>
return result
}()
public init(rootView:Content) {
let container = HostWrapper()
let modified = rootView.environmentObject(container) as! ModifiedContent<Content, _EnvironmentKeyWritingModifier<HostWrapper?>>
super.init(rootView: modified)
container.controller = self
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override func viewDidLoad() {
super.viewDidLoad()

View File

@ -33,7 +33,6 @@ public struct AttributedText: View {
}
public var body: some View {
let _ = print(descriptions)
descriptions.map { description in
var text: Text = Text(description.content)
if let font: Font = description.font { text = text.font(font) }

View File

@ -0,0 +1,15 @@
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import SwiftUI
struct SessionTextField: View {
var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
}
}
struct SessionTextField_Previews: PreviewProvider {
static var previews: some View {
SessionTextField()
}
}