Skip to content

Commit

Permalink
wip: new app logo, updated readme, minor improvements, add localization
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorErrorError committed Dec 3, 2023
1 parent 29a5fd7 commit 5e6be91
Show file tree
Hide file tree
Showing 64 changed files with 1,169 additions and 319 deletions.
16 changes: 12 additions & 4 deletions App/Mochi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

/* Begin PBXBuildFile section */
132862252A17D06300F67EAC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 132862242A17D06300F67EAC /* AppDelegate.swift */; };
1396B9E62A4B72A800B7928A /* PreferenceHostingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1396B9E52A4B72A800B7928A /* PreferenceHostingController.swift */; };
1396B9E62A4B72A800B7928A /* PreferenceHostingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1396B9E52A4B72A800B7928A /* PreferenceHostingController.swift */; platformFilter = ios; };
1396FE0529DF561C00B22132 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1396FE0029DF561C00B22132 /* Assets.xcassets */; };
1396FE0629DF561C00B22132 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1396FE0229DF561C00B22132 /* Preview Assets.xcassets */; };
1396FE0729DF561C00B22132 /* MochiApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1396FE0329DF561C00B22132 /* MochiApp.swift */; };
13EDE7392B166E4500E14998 /* PreferenceHostingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13EDE7382B166E4500E14998 /* PreferenceHostingView.swift */; };
13EDE7392B166E4500E14998 /* PreferenceHostingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13EDE7382B166E4500E14998 /* PreferenceHostingView.swift */; platformFilter = ios; };
13F11CC02B11617D006FFF63 /* App in Frameworks */ = {isa = PBXBuildFile; productRef = 13F11CBF2B11617D006FFF63 /* App */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -245,6 +245,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -294,11 +295,13 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
Expand All @@ -307,6 +310,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -350,10 +354,12 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
name = Release;
Expand All @@ -363,8 +369,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = Shared/mochi.entitlements;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = ..;
DEVELOPMENT_TEAM = A6HC4Y86NJ;
Expand Down Expand Up @@ -402,8 +409,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = Shared/mochi.entitlements;
CURRENT_PROJECT_VERSION = 0;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = ..;
DEVELOPMENT_TEAM = A6HC4Y86NJ;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion App/Shared/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,67 @@
{
"images" : [
{
"filename" : "mochi_logo_2d_v6.png",
"filename" : "App Icon.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"filename" : "App Icon@1x-16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "App Icon@2x-16.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "App Icon@1x-32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "App Icon@2x-32.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "App Icon@1x-128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "App Icon@2x-128.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "App Icon@1x-256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "App Icon@2x-256.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "App Icon@1x-512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "App Icon@2x-512.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions App/Shared/MochiApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct MochiApp: App {
store: appDelegate.store
)
}
.injectPreference()
// Ignoring safe area is required for
// PreferenceHostingView to render outside
// bounds
Expand Down
1 change: 0 additions & 1 deletion App/Shared/mochi-info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<string>mochi</string>
</array>
</dict>
<dict/>
</array>
<key>NSAppTransportSecurity</key>
<dict>
Expand Down
5 changes: 4 additions & 1 deletion App/iOS/PreferenceHostingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ final class Box {
}

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

@MainActor
protocol OpaquePreferenceHostingController: OpaquePreferenceProperties, UIViewController {}
#endif
79 changes: 33 additions & 46 deletions App/iOS/PreferenceHostingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
//
// Created by ErrorErrorError on 11/28/23.
//
// Source: https://gist.github.com/Amzd/01e1f69ecbc4c82c8586dcd292b1d30d
//

import Architecture
import Foundation
import LoggerClient
import SwiftUI
import ViewComponents

#if canImport(UIKit)
@MainActor
Expand All @@ -26,14 +29,40 @@ struct PreferenceHostingView<Content: View>: UIViewControllerRepresentable {
func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {}
}

extension PreferenceHostingView {
func injectPreference() -> some View {
self.modifier(PreferenceModifier())
}
}

private struct PreferenceModifier: ViewModifier, OpaquePreferenceProperties {
@State
var _homeIndicatorAutoHidden = false

func body(content: Content) -> some View {
if #available(iOS 16, *) {
content
.persistentSystemOverlays(_homeIndicatorAutoHidden ? .hidden : .visible)
.onPreferenceChange(HomeIndicatorAutoHiddenPreferenceKey.self) { preference in
_homeIndicatorAutoHidden = preference
}
} else {
// Use swizzle's version
content
}
}
}

extension UIViewController {
static func swizzle() {
Swizzle(UIViewController.self) {
#selector(getter: childForHomeIndicatorAutoHidden) => #selector(__swizzledChildForHomeIndicatorAutoHidden)
if #unavailable(iOS 16) {
Swizzle(UIViewController.self) {
#selector(getter: childForHomeIndicatorAutoHidden) => #selector(swizzled_childForHomeIndicatorAutoHidden)
}
}
}

@objc func __swizzledChildForHomeIndicatorAutoHidden() -> UIViewController? {
@objc func swizzled_childForHomeIndicatorAutoHidden() -> UIViewController? {
if self is OpaquePreferenceHostingController {
return nil
} else {
Expand All @@ -56,45 +85,3 @@ extension UIViewController {
}
}
#endif

// Move to utils?
struct Swizzle {
@discardableResult
init(
_ type: AnyClass,
@SwizzleSelectorsBuilder builder: () -> [SwizzleReplacer]
) {
builder().forEach { $0(type) }
}
}

struct SwizzleReplacer {
let original: Selector
let swizzled: Selector

func callAsFunction(_ type: AnyClass) {
guard let originalMethod = class_getInstanceMethod(type, original),
let swizzledMethod = class_getInstanceMethod(type, swizzled) else {
return
}

method_exchangeImplementations(originalMethod, swizzledMethod)
}
}

@resultBuilder
enum SwizzleSelectorsBuilder {
typealias Component = SwizzleReplacer

static func buildBlock(_ components: Component...) -> [Component] {
components
}
}

infix operator =>

extension Selector {
static func => (original: Selector, swizzled: Selector) -> SwizzleReplacer {
.init(original: original, swizzled: swizzled)
}
}
37 changes: 37 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,19 @@ struct DatabaseClient: _Client {
}
}
//
// DeviceClient.swift
//
//
// Created by ErrorErrorError on 11/29/23.
//
//

struct DeviceClient: _Client {
var dependencies: any Dependencies {
ComposableArchitecture()
}
}
//
// FileClient.swift
//
//
Expand All @@ -737,6 +750,25 @@ struct FileClient: _Client {
}
}
//
// LocalizableClient.swift
//
//
// Created by ErrorErrorError on 12/1/23.
//
//

import Foundation

struct LocalizableClient: _Client {
var dependencies: any Dependencies {
ComposableArchitecture()
}

var resources: [Resource] {
Resource.process("Resources")
}
}
//
// LoggerClient.swift
//
//
Expand Down Expand Up @@ -772,6 +804,7 @@ struct ModuleClient: _Client {
SwiftSoup()
Semaphore()
JSValueCoder()
LoggerClient()
}
}

Expand Down Expand Up @@ -1233,6 +1266,8 @@ struct Settings: _Feature {
Architecture()
BuildClient()
FluidGradient()
ModuleClient()
ModuleLists()
SharedModels()
Styling()
ViewComponents()
Expand Down Expand Up @@ -1325,6 +1360,7 @@ struct Architecture: _Shared {
var dependencies: any Dependencies {
FoundationHelpers()
ComposableArchitecture()
LocalizableClient()
}
}
//
Expand Down Expand Up @@ -1460,3 +1496,4 @@ let package = Package {
.supportedPlatforms {
MochiPlatforms()
}
.defaultLocalization("en")
13 changes: 13 additions & 0 deletions Package/Sources/Clients/DeviceClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// DeviceClient.swift
//
//
// Created by ErrorErrorError on 11/29/23.
//
//

struct DeviceClient: _Client {
var dependencies: any Dependencies {
ComposableArchitecture()
}
}
19 changes: 19 additions & 0 deletions Package/Sources/Clients/LocalizableClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// LocalizableClient.swift
//
//
// Created by ErrorErrorError on 12/1/23.
//
//

import Foundation

struct LocalizableClient: _Client {
var dependencies: any Dependencies {
ComposableArchitecture()
}

var resources: [Resource] {
Resource.process("Resources")
}
}
1 change: 1 addition & 0 deletions Package/Sources/Clients/ModuleClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct ModuleClient: _Client {
SwiftSoup()
Semaphore()
JSValueCoder()
LoggerClient()
}
}

Expand Down
Loading

0 comments on commit 5e6be91

Please sign in to comment.