Skip to content

Commit

Permalink
chore(lint): run lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorErrorError committed Dec 14, 2023
1 parent 1262e20 commit 5aa1187
Show file tree
Hide file tree
Showing 168 changed files with 13,680 additions and 13,548 deletions.
4 changes: 2 additions & 2 deletions .swiftformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
--elseposition same-line
--exponentcase lowercase
--exponentgrouping disabled
--extensionacl on-extension
--extensionacl on-declarations
--fractiongrouping disabled
--funcattributes prev-line
--generictypes
--guardelse same-line
--hexgrouping 4,8
--hexliteralcase uppercase
--ifdef no-indent
--indent 4
--indent 2
--indentcase false
--importgrouping alpha
--linebreaks lf
Expand Down
8 changes: 8 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ excluded:
disabled_rules:
- nesting
- vertical_parameter_alignment_on_call
- extension_access_modifier

opt_in_rules:
- anonymous_argument_in_multiline_closure
Expand Down Expand Up @@ -40,6 +41,7 @@ opt_in_rules:
- identical_operands
- implicit_return
- implicitly_unwrapped_optional
- indentation_width
- joined_default_parameter
- last_where
- literal_expression_end_indentation
Expand Down Expand Up @@ -74,13 +76,19 @@ analyzer_rules:
- unused_import
- unused_declaration

conditional_returns_on_newline:
if_only: true

private_over_fileprivate:
validate_extensions: true
severity: error

force_unwrapping:
severity: error

indentation_width:
indentation_width: 2

line_length:
warning: 150
error: 175
Expand Down
6 changes: 3 additions & 3 deletions App/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import PackageDescription

let package = Package(
name: "app",
products: [],
targets: []
name: "app",
products: [],
targets: []
)
45 changes: 23 additions & 22 deletions App/Shared/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,42 @@ import Foundation
import UIKit

class AppDelegate: UIResponder, UIApplicationDelegate {
let store = Store(
initialState: .init(),
reducer: { AppFeature() }
)

func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
store.send(.internal(.appDelegate(.didFinishLaunching)))
return true
}
let store = Store(
initialState: .init(),
reducer: { AppFeature() }
)

func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
store.send(.internal(.appDelegate(.didFinishLaunching)))
return true
}
}

#elseif canImport(AppKit)
import AppKit

class AppDelegate: NSObject, NSApplicationDelegate {
let store = Store(
initialState: .init(),
reducer: { AppFeature() }
)
let store = Store(
initialState: .init(),
reducer: { AppFeature() }
)

func applicationDidFinishLaunching(_ notification: Notification) {
store.send(.internal(.appDelegate(.didFinishLaunching)))
}
func applicationDidFinishLaunching(_: Notification) {
store.send(.internal(.appDelegate(.didFinishLaunching)))
}

func applicationShouldTerminate(_: NSApplication) -> NSApplication.TerminateReply {
func applicationShouldTerminate(_: NSApplication) -> NSApplication.TerminateReply {
// let viewStore = ViewStore(store)
//
// if viewStore.hasPendingChanges {
// viewStore.send(.appDelegate(.appWillTerminate))
// return .terminateLater
// }
//
.terminateNow
}
.terminateNow

Check warning on line 52 in App/Shared/AppDelegate.swift

View workflow job for this annotation

GitHub Actions / run-swiftlint

Code should be indented using one tab or 2 spaces (indentation_width)
}
}
#endif
106 changes: 53 additions & 53 deletions App/Shared/MochiApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,61 @@ import VideoPlayer

@main
struct MochiApp: App {
#if canImport(UIKit)
@UIApplicationDelegateAdaptor(AppDelegate.self)
#elseif canImport(AppKit)
@NSApplicationDelegateAdaptor(AppDelegate.self)
#endif
var appDelegate
#if canImport(UIKit)
@UIApplicationDelegateAdaptor(AppDelegate.self)
#elseif canImport(AppKit)
@NSApplicationDelegateAdaptor(AppDelegate.self)
#endif
var appDelegate

var body: some Scene {
WindowGroup {
#if os(iOS)
PreferenceHostingView {
AppFeature.View(
store: appDelegate.store
)
}
.injectPreference()
// Ignoring safe area is required for
// PreferenceHostingView to render outside
// bounds
.ignoresSafeArea()
.themeable()
#elseif os(macOS)
AppFeature.View(
store: appDelegate.store
)
.frame(
minWidth: 800,
maxWidth: .infinity,
minHeight: 625,
maxHeight: .infinity
)
.themeable()
#endif
}
#if os(macOS)
.windowStyle(.titleBar)
.commands {
SidebarCommands()
ToolbarCommands()
var body: some Scene {
WindowGroup {
#if os(iOS)
PreferenceHostingView {
AppFeature.View(
store: appDelegate.store
)
}
.injectPreference()
// Ignoring safe area is required for
// PreferenceHostingView to render outside
// bounds
.ignoresSafeArea()
.themeable()
#elseif os(macOS)
AppFeature.View(
store: appDelegate.store
)
.frame(
minWidth: 800,
maxWidth: .infinity,
minHeight: 625,
maxHeight: .infinity
)
.themeable()
#endif
}
#if os(macOS)
.windowStyle(.titleBar)
.commands {
SidebarCommands()
ToolbarCommands()

CommandGroup(replacing: .newItem) {}
}
#endif
CommandGroup(replacing: .newItem) {}
}
#endif

#if os(macOS)
Settings {
SettingsFeature.View(
store: appDelegate.store.scope(
state: \.settings,
action: \.internal.settings
)
)
.themeable()
.frame(width: 412)
}
#endif
#if os(macOS)
Settings {
SettingsFeature.View(
store: appDelegate.store.scope(
state: \.settings,
action: \.internal.settings
)
)
.themeable()
.frame(width: 412)
}
#endif
}
}
60 changes: 30 additions & 30 deletions App/iOS/PreferenceHostingController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// HostingController.swift
// PreferenceHostingController.swift
// mochi
//
// Created by ErrorErrorError on 6/27/23.
Expand All @@ -13,53 +13,53 @@ import UIKit
import ViewComponents

final class PreferenceHostingController<Root: View>: UIHostingController<BoxedView<Root>>, OpaquePreferenceHostingController {
override var prefersHomeIndicatorAutoHidden: Bool { _homeIndicatorAutoHidden }
override var prefersHomeIndicatorAutoHidden: Bool { _homeIndicatorAutoHidden }

var _homeIndicatorAutoHidden = false {
didSet {
setNeedsUpdateOfHomeIndicatorAutoHidden()
}
var _homeIndicatorAutoHidden = false {
didSet {
setNeedsUpdateOfHomeIndicatorAutoHidden()
}
}

private let box: Box
private let box: Box

init(rootView: @escaping () -> Root) {
self.box = .init()
super.init(rootView: .init(box: box, content: rootView))
box.object = self
}
init(rootView: @escaping () -> Root) {
self.box = .init()
super.init(rootView: .init(box: box, content: rootView))
box.object = self
}

@available(*, unavailable)
dynamic required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@available(*, unavailable)
dynamic required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

struct BoxedView<Content: View>: View {
let box: Box
let box: Box

init(box: Box, content: @escaping () -> Content) {
self.content = content
self.box = box
}
init(box: Box, content: @escaping () -> Content) {
self.content = content
self.box = box
}

let content: () -> Content
let content: () -> Content

var body: some View {
content()
.onPreferenceChange(HomeIndicatorAutoHiddenPreferenceKey.self) { isHidden in
box.object?._homeIndicatorAutoHidden = isHidden
}
}
var body: some View {
content()
.onPreferenceChange(HomeIndicatorAutoHiddenPreferenceKey.self) { isHidden in
box.object?._homeIndicatorAutoHidden = isHidden
}
}
}

final class Box {
weak var object: OpaquePreferenceHostingController?
weak var object: OpaquePreferenceHostingController?
}

@MainActor
protocol OpaquePreferenceProperties {
var _homeIndicatorAutoHidden: Bool { get set }
var _homeIndicatorAutoHidden: Bool { get set }
}

@MainActor
Expand Down
Loading

0 comments on commit 5aa1187

Please sign in to comment.