Skip to content

Commit acc3fbf

Browse files
committed
Update package
1 parent 179acc6 commit acc3fbf

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

Sources/Intermodular/Extensions/SwiftUI/Color++.swift

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ extension Color {
2929
}
3030

3131
#if os(iOS) || os(macOS) || os(tvOS)
32-
3332
extension Color {
3433
public static var systemRed: Color {
3534
.init(.systemRed)
@@ -71,11 +70,9 @@ extension Color {
7170
.init(.systemGray)
7271
}
7372
}
74-
7573
#endif
7674

7775
#if os(iOS) || targetEnvironment(macCatalyst)
78-
7976
extension Color {
8077
public static var brown: Color {
8178
return .init(.brown)
@@ -97,11 +94,9 @@ extension Color {
9794
public static let systemGray5: Color = Color(.systemGray5)
9895
public static let systemGray6: Color = Color(.systemGray6)
9996
}
100-
10197
#endif
10298

10399
#if os(iOS) || os(macOS) || os(tvOS) || targetEnvironment(macCatalyst)
104-
105100
/// Foreground colors for static text and related elements.
106101
extension Color {
107102
/// The color for text labels that contain primary content.
@@ -140,11 +135,9 @@ extension Color {
140135
#endif
141136
}
142137
}
143-
144138
#endif
145139

146140
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
147-
148141
extension Color {
149142
/// A foreground color for standard system links.
150143
public static var link: Color {
@@ -161,11 +154,9 @@ extension Color {
161154
return .init(.opaqueSeparator)
162155
}
163156
}
164-
165157
#endif
166158

167159
#if os(iOS) || targetEnvironment(macCatalyst)
168-
169160
extension Color {
170161
/// The color for the main background of your interface.
171162
public static var systemBackground: Color {
@@ -232,7 +223,6 @@ extension Color {
232223
return .init(.quaternarySystemFill)
233224
}
234225
}
235-
236226
#endif
237227

238228
extension Color {
@@ -285,8 +275,6 @@ extension Color {
285275
}
286276
}
287277

288-
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
289-
290278
extension Color {
291279
/// Creates a color from a hexadecimal color code.
292280
///
@@ -376,7 +364,6 @@ extension Color {
376364
// MARK: - Auxiliary Implementation -
377365

378366
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
379-
380367
fileprivate extension UIColor {
381368
class func adaptable(
382369
light: @escaping @autoclosure () -> UIColor,
@@ -418,7 +405,11 @@ fileprivate extension UIColor {
418405
return self
419406
}
420407
}
421-
422408
#endif
423409

410+
#if os(macOS)
411+
extension Color {
412+
/// The color to use for the window background.
413+
public static let windowBackground = Color(NSColor.windowBackgroundColor)
414+
}
424415
#endif

Sources/Intramodular/Activity/AppActivityView.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ public struct AppActivityView: UIViewControllerRepresentable {
2727
}
2828

2929
public func makeUIViewController(context: Context) -> UIViewControllerType {
30-
.init(activityItems: activityItems, applicationActivities: applicationActivities)
30+
let viewController = UIViewControllerType(
31+
activityItems: activityItems,
32+
applicationActivities: applicationActivities
33+
)
34+
35+
viewController.excludedActivityTypes = excludedActivityTypes
36+
37+
return viewController
3138
}
3239

3340
public func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
3441
uiViewController.excludedActivityTypes = excludedActivityTypes
35-
42+
3643
uiViewController.completionWithItemsHandler = { activity, success, items, error in
3744
if let error = error {
3845
self.onComplete(.failure(error))
@@ -56,11 +63,15 @@ extension AppActivityView {
5663
then({ $0.excludedActivityTypes = activityTypes })
5764
}
5865

59-
public func onCancel(perform action: @escaping () -> Void) -> Self {
66+
public func onCancel(
67+
perform action: @escaping () -> Void
68+
) -> Self {
6069
then({ $0.onCancel = action })
6170
}
6271

63-
public func onComplete(perform action: @escaping (Result<(activity: UIActivity.ActivityType, items: [Any]?), Error>) -> Void) -> Self {
72+
public func onComplete(
73+
perform action: @escaping (Result<(activity: UIActivity.ActivityType, items: [Any]?), Error>) -> Void
74+
) -> Self {
6475
then({ $0.onComplete = action })
6576
}
6677
}

Sources/Intramodular/Catalyst/HideTitleBar.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fileprivate struct HideTitleBar: ViewModifier {
99
let isHidden: Bool
1010

1111
func body(content: Content) -> some View {
12-
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
12+
#if os(iOS) || os(macOS) || os(tvOS) || targetEnvironment(macCatalyst)
1313
withAppKitOrUIKitViewController { viewController in
1414
content
1515
.onAppear(perform: { updateTitlebar(for: viewController) })
@@ -21,9 +21,21 @@ fileprivate struct HideTitleBar: ViewModifier {
2121
#endif
2222
}
2323

24-
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
24+
#if os(iOS) || os(macOS) || os(tvOS) || targetEnvironment(macCatalyst)
2525
private func updateTitlebar(for viewController: AppKitOrUIKitViewController?) {
26-
#if targetEnvironment(macCatalyst)
26+
#if os(macOS)
27+
guard let window = viewController?.view.window else {
28+
return
29+
}
30+
31+
if isHidden {
32+
window.titlebarAppearsTransparent = true
33+
window.titleVisibility = .hidden
34+
} else {
35+
window.titlebarAppearsTransparent = false
36+
window.titleVisibility = .visible
37+
}
38+
#elseif targetEnvironment(macCatalyst)
2739
guard let windowScene = viewController?.view.window?.windowScene else {
2840
return
2941
}

0 commit comments

Comments
 (0)