Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove custom navigation bar #5121

Merged
merged 219 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 204 commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
0c790be
Remove WMFRootNavigationController, set up navigation controller in e…
tonisevener May 10, 2024
30e4599
Carefully try to remove ViewController dependency from ExploreViewCon…
tonisevener May 10, 2024
4055954
Progress updating Explore to system navigation bar
tonisevener May 10, 2024
9ba0fea
Some notes
tonisevener May 10, 2024
c1d5039
Remove custom navigation bar from SearchViewController, delete relate…
tonisevener May 15, 2024
d15f73c
Fix search empty state not scrolling nav bar bug
tonisevener May 16, 2024
1bbf839
Search and Explore basic search working
tonisevener May 16, 2024
e2fac55
Fix bottom edge hiding beneath tab bar
tonisevener May 16, 2024
d3f08cf
Playing with scope bar
tonisevener May 17, 2024
a66c7ff
Add search scopes
tonisevener May 20, 2024
d4cf04f
Add Explore safe area overlay
tonisevener May 20, 2024
da0c92c
Progress removing custom navigation bar on Saved tab
tonisevener May 20, 2024
0abe1cd
Progress removing custom navigation bar on History tab
tonisevener May 20, 2024
d10f0e5
Try to fix reading list detail view
tonisevener May 21, 2024
14fe11f
Progress with places
tonisevener May 21, 2024
71e072b
More progress with Places
tonisevener May 24, 2024
9b241d2
Places - Some progress bringing back list overlay for iPad
tonisevener May 28, 2024
80b64c4
More places progress
tonisevener May 28, 2024
5fa42dc
Places - Fix list content hiding under tab bar bug
tonisevener Jun 24, 2024
7a92010
Places - minor cleanup
tonisevener Jun 24, 2024
bbb088a
Progress on top read articles list
tonisevener Jun 24, 2024
12c6392
Fixes to top read articles list
tonisevener Jun 24, 2024
39098f6
Fix Explore > Locations list page
tonisevener Jun 24, 2024
3fbaade
Progress getting places search to work
tonisevener Jun 24, 2024
9b3a4e2
More fixes to Places
tonisevener Jun 25, 2024
f2aa343
Allow reading list detail header view to scroll
tonisevener Jun 26, 2024
dfbe017
Merge branch 'main' into prototype/system-nav-bar
tonisevener Jun 27, 2024
fbbfb19
Fixed on this day list view controller
tonisevener Jun 27, 2024
3d0251b
Fix in the news list view controller
tonisevener Jun 27, 2024
3d7c2f1
Improvements to reading list detail list
tonisevener Jun 28, 2024
38a10cd
Some more fixes to reading list detail header
tonisevener Jun 28, 2024
4c7d277
Fixes for article view
tonisevener Jun 28, 2024
97eb439
Fixes to search from article
tonisevener Jun 28, 2024
768e275
Fixes to image recommendations
tonisevener Jun 28, 2024
2a34ce5
Fix some bugs that article caused
tonisevener Jun 28, 2024
0fc169c
Update settings root view
tonisevener Jun 28, 2024
ee0d629
Update settings subviews
tonisevener Jun 28, 2024
0ffc30b
Update notifications center
tonisevener Jun 28, 2024
a2e2395
Add TestHeaderView to article history in preparation for header rework
tonisevener Jun 28, 2024
cf67379
Tweaks to navigation bar hiding speed so that it's less annoying
tonisevener Jul 1, 2024
fdddbcc
More fixes to reading list detail
tonisevener Jul 1, 2024
872e02f
More reading list detail fixes
tonisevener Jul 1, 2024
b351de4
Refactor PageHistoryFilterCountsViewController into UIView
tonisevener Jul 1, 2024
bbf5075
Complete article history update
tonisevener Jul 1, 2024
6a6fc9e
Update Diff view
tonisevener Jul 1, 2024
857c226
Update talk view
tonisevener Jul 1, 2024
7fd6296
Random article fixes
tonisevener Jul 1, 2024
5807f79
Try to remove random references to ViewController
tonisevener Jul 1, 2024
0c24200
Update add articles to reading list view
tonisevener Jul 2, 2024
e61c229
Update insert image views
tonisevener Jul 2, 2024
83e0726
Fix insert and edit link views
tonisevener Jul 2, 2024
7f3a1ef
Fix Edit Preview
tonisevener Jul 2, 2024
5011045
Progress with reference view controllers
tonisevener Jul 2, 2024
38a5f3e
More fixes to reference view controllers
tonisevener Jul 2, 2024
87d3ce7
Update Description help view
tonisevener Jul 2, 2024
57f59ca
Update talk page coffee roll view
tonisevener Jul 2, 2024
83ebad8
Update talk page topic compose
tonisevener Jul 2, 2024
a7daf63
Prevent article talk header labels from getting clipped
tonisevener Jul 2, 2024
ffce196
Fix dropped navigation animations
tonisevener Jul 2, 2024
ef57cc2
Allow update languages from search tab
tonisevener Jul 2, 2024
80aefcd
Don't briefly show old search results
tonisevener Jul 2, 2024
de688e0
Add sorting back to Saved
tonisevener Jul 2, 2024
53a0e02
Reduce default large header size
tonisevener Jul 2, 2024
1d321b2
Merge branch 'main' into prototype/system-nav-bar
tonisevener Jul 2, 2024
cd01a1a
Some fixes towards smoother Places animation
tonisevener Jul 3, 2024
b662c02
Fix Places list layout
tonisevener Jul 3, 2024
9a447ed
Fix settings large header font size
tonisevener Jul 3, 2024
44bd6ce
More search fixes to prevent flashing
tonisevener Jul 3, 2024
72add08
Changes needed for iPadOS 18
tonisevener Jul 25, 2024
f1ddbba
Revert "Changes needed for iPadOS 18"
tonisevener Sep 23, 2024
0b9364a
Merge branch 'main' into prototype/system-nav-bar
tonisevener Sep 23, 2024
45950ee
Compile fixes
tonisevener Sep 23, 2024
4bf71bb
Some fixes after merge
tonisevener Sep 23, 2024
c57b7f9
Merge branch 'main' into prototype/system-nav-bar
tonisevener Oct 4, 2024
f3749e5
Merge branch 'main' into prototype/system-nav-bar
tonisevener Oct 15, 2024
53121cf
Merge branch 'main' into prototype/system-nav-bar
tonisevener Nov 8, 2024
0acaab1
Bug fixes after merge
tonisevener Nov 8, 2024
624f525
Article and Explore sticky nav fix
tonisevener Nov 8, 2024
0440837
Remove shadow on some nav bars
tonisevener Nov 8, 2024
3bb1af1
Add search bar to Article for demo
tonisevener Nov 8, 2024
073de11
Remove search icon from article
tonisevener Nov 8, 2024
6d63a68
Remove some separators in Saved tab
tonisevener Nov 8, 2024
4765f23
Some iPad article and floating tab bar fixes
tonisevener Nov 14, 2024
076790b
Fix content insets, scrolling of TOC iPad
tonisevener Nov 15, 2024
f32c300
Progress fixing search bar languages before bailing
tonisevener Nov 15, 2024
2a7b06c
Continue fixing search bar languages
tonisevener Nov 16, 2024
d1f9a6f
Bring back iPad margins
tonisevener Nov 18, 2024
4650dda
Merge branch 'main' into prototype/system-nav-bar
tonisevener Nov 18, 2024
0b19d5a
Fix compile failure
tonisevener Nov 20, 2024
00dbda0
In progress
tonisevener Nov 21, 2024
c8583f6
Fix search languages bar animation
tonisevener Nov 22, 2024
71974f5
Disable navigation bar hiding on Explore and Article when searching
tonisevener Nov 22, 2024
a85f23c
Merge branch 'main' into prototype/system-nav-bar
tonisevener Nov 22, 2024
9cdf8ab
Fix some missing hints
tonisevener Nov 22, 2024
db543c7
Merge branch 'main' into prototype/system-nav-bar
tonisevener Dec 9, 2024
2e5635d
Add sorting / searching to reading lists
tonisevener Dec 10, 2024
60c7446
Fix minor annoyances
tonisevener Dec 10, 2024
3db144e
Fix content stutter on article search focus animation
tonisevener Dec 10, 2024
4c2c7ca
Fix for nav bar to reappear upon article scroll up
tonisevener Dec 11, 2024
105b93e
Simplification of insets on article + TOC
tonisevener Dec 11, 2024
c9e1638
Lots of fixes for editor flow, beginnings of shared navigation bar se…
tonisevener Dec 11, 2024
4cb2e41
Edit Preview fixes
tonisevener Dec 11, 2024
e7c2ba8
Fix edit preview Back logging call
tonisevener Dec 11, 2024
622ef2d
Better fixes to restore custom back button handling
tonisevener Dec 11, 2024
50c3436
Fix captcha theming on edit summary
tonisevener Dec 11, 2024
355fd6a
Remove RootNavigationController, use WMFComponentNavigationController
tonisevener Dec 11, 2024
b01c93f
Progress applying shared nav bar setup in Settings
tonisevener Dec 11, 2024
8cd12de
Apply shared nav bar setup to Explore and Article
tonisevener Dec 12, 2024
eb6112d
Delete comments on article
tonisevener Dec 12, 2024
7e975c0
Rework everything to use compact leading style for root views
tonisevener Dec 13, 2024
17c8e6e
Attempt to clean up search communication
tonisevener Dec 13, 2024
dcbfdc1
Edit link search fixes
tonisevener Dec 13, 2024
af2fb8f
More fixes to edit link
tonisevener Dec 13, 2024
f859839
Insert link fixes
tonisevener Dec 13, 2024
f4f7d8c
Use shared configuration method on Saved articles
tonisevener Dec 13, 2024
cc23489
Use shared configuration method on Reading List views
tonisevener Dec 13, 2024
e01893c
Delete places comments
tonisevener Dec 13, 2024
1d8e712
Use shared configuration method on Places
tonisevener Dec 13, 2024
94c165f
Configure reading list detail nav bar
tonisevener Dec 13, 2024
8f20413
Explore and Article overlay theming fixes
tonisevener Dec 13, 2024
7aff86d
setup Login and Create Account navigation bar
tonisevener Dec 13, 2024
d802b72
Some theming fixes for search results
tonisevener Dec 13, 2024
f6e9459
Maybe fix pop gesture recognizers
tonisevener Dec 14, 2024
b33325f
Saved fixes
tonisevener Dec 15, 2024
282b320
Fix missing back long press titles sometimes
tonisevener Dec 16, 2024
b0a7e22
Temp - force full title in back button
tonisevener Dec 16, 2024
07a72d3
Design feedback - default "back" label handling, large title style fo…
tonisevener Dec 16, 2024
08b5712
Move in-app web view to new navigation bar configuration
tonisevener Dec 16, 2024
2c3eec6
Fix wonky pull to refresh
tonisevener Dec 17, 2024
f879ca3
Fix some places bugs
tonisevener Dec 17, 2024
d2c5cc0
Fix bad transition from History
tonisevener Dec 17, 2024
99f11a9
Always prefer large titles
tonisevener Dec 17, 2024
12cd496
Theming fix to Explore on iPad
tonisevener Dec 17, 2024
f743109
Configure nav bar for disambiguation and page issues
tonisevener Dec 17, 2024
662d101
Configure language picker navigation bars
tonisevener Dec 17, 2024
1a66048
Configure notification center nav bars
tonisevener Dec 17, 2024
d4e5671
Use better X button on gallery
tonisevener Dec 17, 2024
db0d6eb
Fix status bar style
tonisevener Dec 17, 2024
39f7497
Apply navigation bar to explore list views - related, top read, on th…
tonisevener Dec 17, 2024
44f30da
Progress with iPadOS 18 search tab, will revert
tonisevener Dec 17, 2024
2fa1a72
Revert "Progress with iPadOS 18 search tab, will revert"
tonisevener Dec 17, 2024
627104d
Temp move X buttons to Done
tonisevener Dec 17, 2024
1413823
Configure article description editing
tonisevener Dec 17, 2024
6e41d0e
Fix places nav bar
tonisevener Dec 17, 2024
13c1e63
Temp - hide root navigation bars
tonisevener Dec 18, 2024
facd05f
Revert "Temp - hide root navigation bars"
tonisevener Dec 18, 2024
3eab67f
Configure nav bar for donate view controllers
tonisevener Dec 18, 2024
f3337f0
Remove some uses of WMFThemeableNavigationController for login and re…
tonisevener Dec 18, 2024
49c8a29
Configure nav bar for insert media / insert settings
tonisevener Dec 18, 2024
2d59a45
Replace more WMFThemeableNavigationControllers
tonisevener Dec 18, 2024
2c5c149
Configure explore feed settings nav bar
tonisevener Dec 18, 2024
2dfbd39
Configure nav bar for login flows
tonisevener Dec 18, 2024
87c2f8d
Configure nav bars from About the App
tonisevener Dec 18, 2024
663579f
Remove WMFThemeableNavigationController from talk pages
tonisevener Dec 18, 2024
ab20161
Remove legacy WMFThemeableNavigationController & utility methods
tonisevener Dec 18, 2024
f2c058a
Configure talk page new topic nav bar
tonisevener Dec 19, 2024
ae86fcf
Configure SwiftUI modals with new shared nav bar config
tonisevener Dec 19, 2024
d3cd992
Configure description help view controller nav bar
tonisevener Dec 19, 2024
6b7d775
Remove outdated UIBarButtonItem helper methods
tonisevener Dec 19, 2024
9987562
Swap some close buttons over to SFSymbol
tonisevener Dec 19, 2024
53209e9
Bring back over full screen modal presentation style
tonisevener Dec 19, 2024
042c1b9
Remove unnecessary done button theming
tonisevener Dec 19, 2024
c3709bf
Configure navigation bar with image recommendations
tonisevener Dec 19, 2024
9752506
Fix some toolbar theming
tonisevener Dec 19, 2024
6a3a1ae
Edit / insert link theming fixes
tonisevener Dec 19, 2024
231a166
Use leading button for in-app web view
tonisevener Dec 19, 2024
8b8fadb
Merge branch 'main' into prototype/system-nav-bar
tonisevener Dec 19, 2024
8fab877
Strings changes from building
tonisevener Dec 19, 2024
74baa73
Fix diff crash
tonisevener Dec 20, 2024
557a3e3
Fix bad layout on talk page coffee roll
tonisevener Dec 20, 2024
2f75ef2
Added some missing navigation bar configurations
tonisevener Dec 20, 2024
e619a1e
Fix wonky refresh again
tonisevener Dec 20, 2024
c642fa7
Delete code that seems unnecessary now
tonisevener Dec 20, 2024
c6e0b2c
Do not let ArticleLocationCollectionViewController change places nav …
tonisevener Dec 20, 2024
5a131d6
Move AAALD over to ColumnarCollectionViewController2
tonisevener Dec 20, 2024
088f229
Delete old base classes
tonisevener Dec 20, 2024
f1cddb1
Rename new base classes to old base class names
tonisevener Dec 20, 2024
fa0ba37
Remove more base classes, rework talk page archives
tonisevener Dec 20, 2024
686845d
Fix description help view controller nav bar, top read back button
tonisevener Dec 20, 2024
cdfd588
Fixes to legacy empty states
tonisevener Jan 8, 2025
674a541
Fixes to talk page and diff empty state
tonisevener Jan 8, 2025
9752cc9
Merge branch 'main' into prototype/system-nav-bar
tonisevener Jan 8, 2025
c88f983
Fix random warnings, strings changes after merge
tonisevener Jan 8, 2025
b649148
Refactor top safe area overlay and sticky fix into shared extension
tonisevener Jan 8, 2025
23dc8bd
Hide Saved nav bar on scroll
tonisevener Jan 8, 2025
b0df8b4
Hide History nav bar on scroll
tonisevener Jan 9, 2025
b700482
Hide Search nav bar on scroll
tonisevener Jan 9, 2025
44eea8f
Fixes to saved bar hiding
tonisevener Jan 9, 2025
e62f434
Hide Settings bar on scroll
tonisevener Jan 9, 2025
8cf414f
Fix missing Places large title on iPad
tonisevener Jan 9, 2025
7f51988
Move Saved Edit/Sort buttons into More menu, switch to Cancel in edit…
tonisevener Jan 9, 2025
d8e0d3f
Fix bottom space on iPad
tonisevener Jan 9, 2025
e0f5595
Add search button back into Article, pop/dismiss on search cancel
tonisevener Jan 9, 2025
f73f4f7
Merge branch 'main' into prototype/system-nav-bar
tonisevener Jan 9, 2025
d99153f
Wrong title on search
tonisevener Jan 9, 2025
912d85e
Merge branch 'main' into prototype/system-nav-bar
tonisevener Jan 10, 2025
0695dbd
Strings changes from building
tonisevener Jan 10, 2025
b99286e
Code cleanup part 1
tonisevener Jan 10, 2025
0c2b16d
Code cleanup part 2
tonisevener Jan 10, 2025
558b1b3
Close cleanup part 3
tonisevener Jan 10, 2025
d170372
Compile fixes, strings changes from building
tonisevener Jan 10, 2025
3f0051d
Set empty titles as hidden
tonisevener Jan 10, 2025
afe81b0
Fix crash with Article iPad feature announcement
tonisevener Jan 10, 2025
2bbd7af
Minor comment tweak
tonisevener Jan 10, 2025
398b4fd
PR Feedback - indent
tonisevener Jan 15, 2025
c2362ae
PR Feedback - move navigation bar protocols into separate files
tonisevener Jan 15, 2025
7ea1125
PR Feedback - duplicate backgroundColor setting
tonisevener Jan 15, 2025
6e2f0a9
PR Feedback - use closure instead of DiffHeaderTitleViewTapDelegate
tonisevener Jan 15, 2025
f330293
PR Feedback - Use closure instead of DiffHeaderActionDelegate
tonisevener Jan 15, 2025
752c54c
PR Feedback - Use closure instead of SearchResultsViewControllerDelegate
tonisevener Jan 15, 2025
ff216ba
PR Feedback - Use closure instead of SearchViewControllerRecentlySear…
tonisevener Jan 15, 2025
02d67aa
PR Feedback - Use closure instead of SearchViewControllerResultSelect…
tonisevener Jan 15, 2025
a50d946
Merge branch 'main' into prototype/system-nav-bar
tonisevener Jan 15, 2025
af19648
Strings changes from building
tonisevener Jan 15, 2025
02aa875
Merge branch 'main' into prototype/system-nav-bar
tonisevener Jan 16, 2025
162fd48
Strings changes from building
tonisevener Jan 16, 2025
e572be6
PR Feedback - Remove test code
tonisevener Jan 16, 2025
b24adf6
Merge branch 'main' into prototype/system-nav-bar
mazevedofs Jan 17, 2025
0b3e909
Merge branch 'main' into prototype/system-nav-bar
tonisevener Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion WMF Framework/CollectionViewEditController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public class CollectionViewEditController: NSObject, UIGestureRecognizerDelegate
rightButton?.tag = editingState.tag
rightButton?.isEnabled = isRightBarButtonEnabled

let font = WMFFont.for(.boldHeadline)
let font = WMFFont.for(.body)
let attributes = [NSAttributedString.Key.font: font]
rightButton?.setTitleTextAttributes(attributes, for: .normal)
leftButton?.setTitleTextAttributes(attributes, for: .normal)
Expand Down
4 changes: 3 additions & 1 deletion WMF Framework/CommonStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public class CommonStrings: NSObject {
@objc public static let userTitle = WMFLocalizedString("user-title", value: "User", comment: "Text that refers to a user in the app")


@objc public static let doneTitle = WMFLocalizedString("description-published-button-title", value: "Done", comment: "Title for description panel done button.")
@objc public static let doneTitle = WMFLocalizedString("description-published-button-title", value: "Done", comment: "Title for done button.")
public static let goBackTitle = WMFLocalizedString("button-go-back", value: "Go back", comment: "Button text for Go back button used in various places")
public static let publishAnywayTitle = WMFLocalizedString("button-publish-anyway", value: "Publish anyway", comment: "Button text for publish button used when first warned against publishing.")

Expand Down Expand Up @@ -647,6 +647,8 @@ public class CommonStrings: NSObject {

public static let editContextMenuTitle = WMFLocalizedString("edit-menu-item", value: "Edit", comment: "Button label for 'Edit' context menu item")

public static let editorTitle = WMFLocalizedString("editor-title", value: "Editor", comment: "Title of editor view.")

public static let editSource = WMFLocalizedString("editor-edit-source", value: "Edit source", comment: "Title for menu option to edit the source of a page.")

public static let editPublishedToastTitle = WMFLocalizedString("editor-edit-published", value: "Your edit was published.", comment: "Title for alert informing that the user's new edit was successfully published.")
Expand Down
894 changes: 0 additions & 894 deletions WMF Framework/NavigationBar.swift

This file was deleted.

5 changes: 1 addition & 4 deletions WMF Framework/NavigationState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public struct NavigationState: Codable {
public var readingListURIString: String?

public var searchTerm: String?

public var shouldShowNavigationBar: Bool?

public var contentGroupIDURIString: String?

Expand All @@ -86,7 +84,7 @@ public struct NavigationState: Codable {

// TODO: Remove after moving to Swift 5.1 -
// https://github.com/apple/swift-evolution/blob/master/proposals/0242-default-values-memberwise.md
public init(url: URL? = nil, selectedIndex: Int? = nil, articleKey: String? = nil, articleSectionAnchor: String? = nil, talkPageSiteURLString: String? = nil, talkPageTitle: String? = nil, talkPageTypeRawValue: Int? = nil, currentSavedViewRawValue: Int? = nil, readingListURIString: String? = nil, searchTerm: String? = nil, shouldShowNavigationBar: Bool? = nil, contentGroupIDURIString: String? = nil, presentedContentGroupKey: String? = nil) {
public init(url: URL? = nil, selectedIndex: Int? = nil, articleKey: String? = nil, articleSectionAnchor: String? = nil, talkPageSiteURLString: String? = nil, talkPageTitle: String? = nil, talkPageTypeRawValue: Int? = nil, currentSavedViewRawValue: Int? = nil, readingListURIString: String? = nil, searchTerm: String? = nil, contentGroupIDURIString: String? = nil, presentedContentGroupKey: String? = nil) {
self.url = url
self.selectedIndex = selectedIndex
self.articleKey = articleKey
Expand All @@ -97,7 +95,6 @@ public struct NavigationState: Codable {
self.currentSavedViewRawValue = currentSavedViewRawValue
self.readingListURIString = readingListURIString
self.searchTerm = searchTerm
self.shouldShowNavigationBar = shouldShowNavigationBar
self.contentGroupIDURIString = contentGroupIDURIString
self.presentedContentGroupKey = presentedContentGroupKey
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,60 @@ import Combine
/// SwiftUI `View` via `UIHostingController` based Component
open class WMFComponentHostingController<HostedView: View>: UIHostingController<HostedView> {

// MARK: - Private Properties
// MARK: - Private Properties

private var cancellables = Set<AnyCancellable>()
private var cancellables = Set<AnyCancellable>()

// MARK: - Public Properties
// MARK: - Public Properties

var appEnvironment: WMFAppEnvironment {
return WMFAppEnvironment.current
}
var appEnvironment: WMFAppEnvironment {
return WMFAppEnvironment.current
}

var theme: WMFTheme {
return WMFAppEnvironment.current.theme
}
var theme: WMFTheme {
return WMFAppEnvironment.current.theme
}

// MARK: - Public
// MARK: - Public

public override init(rootView: HostedView) {
super.init(rootView: rootView)
subscribeToAppEnvironmentChanges()
}
public override init(rootView: HostedView) {
super.init(rootView: rootView)
subscribeToAppEnvironmentChanges()
setup()
}

public override init?(coder aDecoder: NSCoder, rootView: HostedView) {
super.init(coder: aDecoder, rootView: rootView)
subscribeToAppEnvironmentChanges()
}
public override init?(coder aDecoder: NSCoder, rootView: HostedView) {
super.init(coder: aDecoder, rootView: rootView)
subscribeToAppEnvironmentChanges()
setup()
}

public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
subscribeToAppEnvironmentChanges()
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
subscribeToAppEnvironmentChanges()
setup()
}

// MARK: - WMFAppEnvironment Subscription
// MARK: - Lifecycle

private func subscribeToAppEnvironmentChanges() {
WMFAppEnvironment.publisher
.sink(receiveValue: { [weak self] _ in self?.appEnvironmentDidChange() })
.store(in: &cancellables)
}
private func setup() {

}

// MARK: - Subclass Overrides
// MARK: - WMFAppEnvironment Subscription

public func appEnvironmentDidChange() {
// Subclasses should implement
}
private func subscribeToAppEnvironmentChanges() {
WMFAppEnvironment.publisher
.sink(receiveValue: { [weak self] _ in self?.appEnvironmentDidChange() })
.store(in: &cancellables)
}

// MARK: - Subclass Overrides

public func appEnvironmentDidChange() {
overrideUserInterfaceStyle = appEnvironment.theme.userInterfaceStyle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tiny: can we indent this

setNeedsStatusBarAppearanceUpdate()
// Subclasses should implement
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import UIKit
import Combine

open class WMFComponentNavigationController: UINavigationController {

// MARK: - Private Properties

private var cancellables = Set<AnyCancellable>()

// MARK: - Public Properties

var appEnvironment: WMFAppEnvironment {
return WMFAppEnvironment.current
}

var theme: WMFTheme {
return WMFAppEnvironment.current.theme
}

var forcePortrait = false

// MARK: - Public

@objc public convenience init(rootViewController: UIViewController, modalPresentationStyle: UIModalPresentationStyle) {
self.init(rootViewController: rootViewController)
self.modalPresentationStyle = modalPresentationStyle
}

public override init(rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
subscribeToAppEnvironmentChanges()
setup()
}

open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

setBarAppearance()
}

required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return forcePortrait ? .portrait : topViewController?.supportedInterfaceOrientations ?? .all
}

open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return topViewController?.preferredInterfaceOrientationForPresentation ?? .portrait
}

public func turnOnForcePortrait() {
forcePortrait = true
}

public func turnOffForcePortrait() {
forcePortrait = false
}

// MARK: - AppEnvironment Subscription

private func subscribeToAppEnvironmentChanges() {
WMFAppEnvironment.publisher
.sink(receiveValue: { [weak self] _ in self?.appEnvironmentDidChange() })
.store(in: &cancellables)
}

// MARK: - Subclass Overrides

public func appEnvironmentDidChange() {
overrideUserInterfaceStyle = theme.userInterfaceStyle
setNeedsStatusBarAppearanceUpdate()

setBarAppearance()
}

private func setBarAppearance() {

let barAppearance = UINavigationBarAppearance()
barAppearance.configureWithOpaqueBackground()
barAppearance.largeTitleTextAttributes = [.font: WMFFont.navigationBarLeadingLargeTitleFont]

if modalPresentationStyle == .pageSheet {
barAppearance.backgroundColor = theme.midBackground
let backgroundImage = UIImage.roundedRectImage(with: theme.midBackground, cornerRadius: 1)
barAppearance.backgroundImage = backgroundImage
} else {
barAppearance.backgroundColor = theme.paperBackground
let backgroundImage = UIImage.roundedRectImage(with: theme.paperBackground, cornerRadius: 1)
barAppearance.backgroundImage = backgroundImage
}

barAppearance.shadowImage = UIImage()
barAppearance.shadowColor = .clear

navigationBar.tintColor = theme.navigationBarTintColor
navigationBar.standardAppearance = barAppearance
navigationBar.scrollEdgeAppearance = barAppearance
navigationBar.compactAppearance = barAppearance
}

open override var preferredStatusBarStyle: UIStatusBarStyle {
return theme.preferredStatusBarStyle
}

// MARK: - Private

private func setup() {
interactivePopGestureRecognizer?.delegate = self
}

}

extension WMFComponentNavigationController: UIGestureRecognizerDelegate {
public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return viewControllers.count > 0
}

public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
if gestureRecognizer is UIScreenEdgePanGestureRecognizer {
return false
}

return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,47 @@ import Combine
/// UIKit `UIView` based Component
public class WMFComponentView: UIView {

// MARK: - Private Properties
// MARK: - Private Properties

private var cancellables = Set<AnyCancellable>()
private var cancellables = Set<AnyCancellable>()

// MARK: - Public Properties
// MARK: - Public Properties

var appEnvironment: WMFAppEnvironment {
return WMFAppEnvironment.current
}
var appEnvironment: WMFAppEnvironment {
return WMFAppEnvironment.current
}

var theme: WMFTheme {
return WMFAppEnvironment.current.theme
}
var theme: WMFTheme {
return WMFAppEnvironment.current.theme
}

// MARK: - Public
// MARK: - Public

public override init(frame: CGRect) {
super.init(frame: frame)
translatesAutoresizingMaskIntoConstraints = false
subscribeToAppEnvironmentChanges()
}
public override init(frame: CGRect) {
super.init(frame: frame)
translatesAutoresizingMaskIntoConstraints = false
subscribeToAppEnvironmentChanges()
}

public required init?(coder: NSCoder) {
super.init(coder: coder)
translatesAutoresizingMaskIntoConstraints = false
subscribeToAppEnvironmentChanges()
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
translatesAutoresizingMaskIntoConstraints = false
subscribeToAppEnvironmentChanges()
}

// MARK: - AppEnvironment Subscription
// MARK: - AppEnvironment Subscription

private func subscribeToAppEnvironmentChanges() {
WMFAppEnvironment.publisher
.sink(receiveValue: { [weak self] _ in self?.appEnvironmentDidChange() })
.store(in: &cancellables)
}
private func subscribeToAppEnvironmentChanges() {
WMFAppEnvironment.publisher
.sink(receiveValue: { [weak self] _ in self?.appEnvironmentDidChange() })
.store(in: &cancellables)
}

// MARK: - Subclass Overrides
// MARK: - Subclass Overrides

public func appEnvironmentDidChange() {
overrideUserInterfaceStyle = appEnvironment.theme.userInterfaceStyle
// Subclasses should implement
}

public func appEnvironmentDidChange() {
// Subclasses should implement
}

}
Loading