Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
divadretlaw committed Apr 12, 2024
1 parent 155ea4e commit 6ec6717
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 47 deletions.
19 changes: 15 additions & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ disabled_rules: # rule identifiers turned on by default to exclude from running
# - compiler_protocol_init
# - computed_accessors_order
# - control_statement
# - custom_rules
# - cyclomatic_complexity
# - deployment_target
# - discouraged_direct_init
Expand All @@ -27,7 +26,7 @@ disabled_rules: # rule identifiers turned on by default to exclude from running
# - for_where
# - force_cast
# - force_try
# - function_body_length
- function_body_length
# - function_parameter_count
# - generic_type_name
# - identifier_name
Expand All @@ -49,6 +48,7 @@ disabled_rules: # rule identifiers turned on by default to exclude from running
# - nesting
# - no_fallthrough_only
# - no_space_in_method_call
# - non_optional_string_data_conversion
# - notification_center_detachment
# - ns_number_init_as_function_reference
# - nsobject_prefer_isequal
Expand All @@ -69,6 +69,7 @@ disabled_rules: # rule identifiers turned on by default to exclude from running
# - self_in_property_initialization
# - shorthand_operator
# - statement_position
# - static_over_final_class
# - superfluous_disable_command
# - switch_case_alignment
# - syntactic_sugar
Expand All @@ -81,6 +82,8 @@ disabled_rules: # rule identifiers turned on by default to exclude from running
# - type_name
# - unavailable_condition
# - unneeded_break_in_switch
# - unneeded_override
# - unneeded_synthesized_initializer
# - unused_closure_parameter
# - unused_control_flow_label
# - unused_enumerated
Expand All @@ -96,6 +99,7 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- accessibility_label_for_image
- accessibility_trait_for_button
# - anonymous_argument_in_multiline_closure
- anyobject_protocol
- array_init
# - attributes
- balanced_xctest_lifecycle
Expand Down Expand Up @@ -137,6 +141,7 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
# - file_name
- file_name_no_space
# - file_types_order
# - final_test_case
- first_where
- flatmap_over_map_reduce
- force_unwrapping
Expand All @@ -146,6 +151,7 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- implicit_return
- implicitly_unwrapped_optional
# - indentation_width
# - inert_defer
- joined_default_parameter
- last_where
- legacy_multiple
Expand All @@ -154,7 +160,7 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- literal_expression_end_indentation
- local_doc_comment
- lower_acl_than_parent
# - missing_docs
- missing_docs
- modifier_order
- multiline_arguments
# - multiline_arguments_brackets
Expand All @@ -166,10 +172,12 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
# - no_extension_access_modifier
- no_grouping_extension
# - no_magic_numbers
# - non_overridable_class_declaration
- nslocalizedstring_key
# - nslocalizedstring_require_bundle
- number_separator
- object_literal
# - one_declaration_per_file
- operator_usage_whitespace
- optional_enum_case_matching
- overridden_super_call
Expand All @@ -184,6 +192,7 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- private_action
- private_outlet
# - private_subject
- private_swiftui_state
- prohibited_interface_builder
- prohibited_super_call
- quick_discouraged_call
Expand All @@ -198,6 +207,7 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- required_enum_case
- return_value_from_void_function
- self_binding
# - shorthand_argument
# - shorthand_optional_binding
- single_test_class
# - sorted_enum_cases
Expand All @@ -218,6 +228,7 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
# - unused_capture_list
# - unused_declaration
# - unused_import
- vertical_parameter_alignment_on_call
Expand All @@ -229,4 +240,4 @@ opt_in_rules: # some rules are turned off by default, so you need to opt-in
- yoda_condition

included:
- Sources
- Sources
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/divadretlaw/WindowReader",
"state" : {
"revision" : "03c1db131e860315721e71501bb056c08c9c0153",
"version" : "1.3.0"
"revision" : "7e1f994df0ed26a7d7a139f1fce2537d2c931059",
"version" : "2.0.0"
}
},
{
"identity" : "windowscenereader",
"kind" : "remoteSourceControl",
"location" : "https://github.com/divadretlaw/WindowSceneReader",
"state" : {
"revision" : "5f66d4d5eec1ee6a0d2ea14bb17007b5625bf10d",
"version" : "2.2.0"
"revision" : "0779fbf801a723570f90158aa5e618ff885b6c47",
"version" : "3.0.0"
}
}
],
Expand Down
37 changes: 0 additions & 37 deletions Sources/WindowKit/WindowCover/WindowCover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ struct WindowCover<WindowContent>: ViewModifier where WindowContent: View {
@ObservedObject private var windowManager = WindowManager.shared
@EnvironmentInjectedObject private var environmentHolder: EnvironmentValuesHolder

// FIXME: Workaround for initially wrong environment values
private final class EnvironmentResolver: ObservableObject {
@Published var colorScheme: ColorScheme?
@Published var timeZone: TimeZone?
}
@StateObject private var environmentResolver = EnvironmentResolver()
@Environment(\.colorScheme) private var colorScheme
@Environment(\.timeZone) private var timeZone

@WindowIdentifier private var identifier

func body(content: Content) -> some View {
Expand Down Expand Up @@ -67,21 +58,6 @@ struct WindowCover<WindowContent>: ViewModifier where WindowContent: View {
guard value == key else { return }
isPresented = false
}
#if os(visionOS)
.onChange(of: colorScheme) { _, colorScheme in
environmentResolver.colorScheme = colorScheme
}
.onChange(of: timeZone) { _, timeZone in
environmentResolver.timeZone = timeZone
}
#else
.onChange(of: colorScheme) { colorScheme in
environmentResolver.colorScheme = colorScheme
}
.onChange(of: timeZone) { timeZone in
environmentResolver.timeZone = timeZone
}
#endif
} else {
content
#if os(visionOS)
Expand Down Expand Up @@ -115,19 +91,6 @@ struct WindowCover<WindowContent>: ViewModifier where WindowContent: View {
WindowView(environment: environmentHolder) {
windowContent()
.applyTint(configuration.color)
// FIXME: Workaround for initially wrong environment values
.transformEnvironment(\.self) { environment in
// Some properties like 'colorScheme' that may update dynamically
// get copied, but then don't update for the initial presentation.
// Subsequent presentations after a dynamic change seem to get
// propagated just fine.
if let colorScheme = environmentResolver.colorScheme {
environment.colorScheme = colorScheme
}
if let timeZone = environmentResolver.timeZone {
environment.timeZone = timeZone
}
}
}
.transformEnvironment { values in
if let colorScheme = configuration.colorScheme {
Expand Down
2 changes: 0 additions & 2 deletions Sources/WindowKit/WindowOverlay/WindowOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ struct WindowOverlay<WindowContent>: ViewModifier, DynamicProperty where WindowC
@ObservedObject private var windowManager = WindowManager.shared
@EnvironmentInjectedObject private var environmentHolder: EnvironmentValuesHolder

@State private var hostingController: WindowOverlayHostingController<AnyView>?

@WindowIdentifier private var identifier

func body(content: Content) -> some View {
Expand Down

0 comments on commit 6ec6717

Please sign in to comment.