Skip to content

Commit

Permalink
fixup! Convert ConfirmationView form UIKit to SwiftUI
Browse files Browse the repository at this point in the history
This PR is experimental, yet important first step towards transitioning
to SwiftUI. ConfirmationView has been rewritten entirely in SwiftUI. The
primary motivator for this PR was the frustrating nature of UIKit constraints.

Key factors to keep in mind while reviewing:

1. Checkmark image has been made smaller, which was the request from the
design team

2. UIFont does not translate 1:1 to SwiftUI Font, meaning the same font
looks just a little big different now. But dynamic scaling works, and all
our default fonts translate to expected outcome (font size, weight etc.)

3. Some approaches used in view layouts is due to the restrictions of
SwiftUI 1.0 capabilities. Those can and will be upgraded in the future

4. The naming of Views, and Objects, as well as file locations in the
directory are up for discussion. Everyone's input is much appreciated.

5. Prefix SwiftUI is used in lots of places due to a conflict with existing
custom objects Button and Image

6. New HeaderSwiftUI view does not include all the possible configuration
possibilities, as confirmations view's needs are not very demanding. So,
that view can be upgraded in future.

This PR also covers the ticket MOB-2488 which focuses on ADA-compliance
in ConfigurationsView
  • Loading branch information
rasmustautsglia committed Sep 15, 2023
1 parent 17fd549 commit 58bba1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ extension SecureConversations {
addChild(hostingController)
view.addSubview(hostingController.view)
hostingController.didMove(toParent: self)

hostingController.rootView = ConfirmationViewSwiftUI(
model: model,
orientation: orientation
)

Check warning on line 38 in GliaWidgets/SecureConversations/Confirmation/SecureConversations.ConfirmationViewController.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
Expand Down
6 changes: 3 additions & 3 deletions GliaWidgets/SwiftUI/Managers/OrientationManager.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import SwiftUI
import Combine

class OrientationManager: ObservableObject {
final class OrientationManager: ObservableObject {
@Published private(set) var orientation: UIInterfaceOrientation

private let environment: Environment
private var orientationSubscription: AnyCancellable?
private var currentOrientation: UIInterfaceOrientation {
environment.uiApplication.windows().first?.windowScene?.interfaceOrientation ?? .unknown
environment.uiApplication.windows().first?.windowScene?.interfaceOrientation ?? .portrait
}

var isPortrait: Bool {
Expand All @@ -20,7 +20,7 @@ class OrientationManager: ObservableObject {

init(environment: Environment) {
self.environment = environment
orientation = environment.uiApplication.windows().first?.windowScene?.interfaceOrientation ?? .unknown
orientation = environment.uiApplication.windows().first?.windowScene?.interfaceOrientation ?? .portrait
orientationSubscription = environment.notificationCenter
.publisherForNotification(environment.uiDevice.orientationDidChangeNotification())
.map { _ in self.currentOrientation }
Expand Down

0 comments on commit 58bba1e

Please sign in to comment.