Add branding and style bars (#4)

This commit is contained in:
Nathan Mattes 2023-08-10 11:21:45 +02:00
parent 975705c3f2
commit 98533427a7
7 changed files with 220 additions and 6 deletions

View File

@ -16,6 +16,8 @@
D81FE79B2A83EB19004251A3 /* ArtistsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81FE79A2A83EB19004251A3 /* ArtistsTableViewCell.swift */; };
D81FE79D2A83EEB6004251A3 /* FunkwhaleCollectionResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81FE79C2A83EEB6004251A3 /* FunkwhaleCollectionResponse.swift */; };
D81FE79F2A83F0C0004251A3 /* Artist.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81FE79E2A83F0C0004251A3 /* Artist.swift */; };
D81FE7A92A84DE81004251A3 /* Branding.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81FE7A82A84DE81004251A3 /* Branding.swift */; };
D81FE7AD2A84E025004251A3 /* XCAssets+Generated.swift in Sources */ = {isa = PBXBuildFile; fileRef = D81FE7AC2A84E025004251A3 /* XCAssets+Generated.swift */; };
D885CF6A2A825549004CE828 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D885CF692A825549004CE828 /* AppDelegate.swift */; };
D885CF6C2A825549004CE828 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D885CF6B2A825549004CE828 /* SceneDelegate.swift */; };
D885CF6E2A825549004CE828 /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D885CF6D2A825549004CE828 /* RootViewController.swift */; };
@ -51,6 +53,9 @@
D81FE79A2A83EB19004251A3 /* ArtistsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArtistsTableViewCell.swift; sourceTree = "<group>"; };
D81FE79C2A83EEB6004251A3 /* FunkwhaleCollectionResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FunkwhaleCollectionResponse.swift; sourceTree = "<group>"; };
D81FE79E2A83F0C0004251A3 /* Artist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Artist.swift; sourceTree = "<group>"; };
D81FE7A82A84DE81004251A3 /* Branding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Branding.swift; sourceTree = "<group>"; };
D81FE7AA2A84DF5D004251A3 /* swiftgen.yml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; name = swiftgen.yml; path = ../../../swiftgen.yml; sourceTree = "<group>"; };
D81FE7AC2A84E025004251A3 /* XCAssets+Generated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCAssets+Generated.swift"; sourceTree = "<group>"; };
D885CF662A825549004CE828 /* pinniped-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "pinniped-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D885CF692A825549004CE828 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
D885CF6B2A825549004CE828 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
@ -143,10 +148,12 @@
isa = PBXGroup;
children = (
D885CF9C2A82678A004CE828 /* Strings+Generated.swift */,
D81FE7AC2A84E025004251A3 /* XCAssets+Generated.swift */,
D885CF9A2A82659D004CE828 /* Localizable.strings */,
D885CF742A82554A004CE828 /* LaunchScreen.storyboard */,
D885CF722A82554A004CE828 /* Assets.xcassets */,
D885CF772A82554A004CE828 /* Info.plist */,
D81FE7AA2A84DF5D004251A3 /* swiftgen.yml */,
);
path = Resources;
sourceTree = "<group>";
@ -169,6 +176,7 @@
D885CF6D2A825549004CE828 /* RootViewController.swift */,
D885CF862A82631B004CE828 /* Onboarding */,
D81FE7932A83E976004251A3 /* Artists */,
D81FE7A82A84DE81004251A3 /* Branding.swift */,
);
path = View;
sourceTree = "<group>";
@ -320,6 +328,7 @@
D81FE79F2A83F0C0004251A3 /* Artist.swift in Sources */,
D885CF822A825DBB004CE828 /* Coordinator.swift in Sources */,
D885CF9D2A82678A004CE828 /* Strings+Generated.swift in Sources */,
D81FE7A92A84DE81004251A3 /* Branding.swift in Sources */,
D885CF882A826322004CE828 /* OnboardingCoordinator.swift in Sources */,
D885CFA52A838E33004CE828 /* ConnectToFunkwhaleTableViewCell.swift in Sources */,
D885CF6E2A825549004CE828 /* RootViewController.swift in Sources */,
@ -337,6 +346,7 @@
D81FE79B2A83EB19004251A3 /* ArtistsTableViewCell.swift in Sources */,
D885CF922A82652D004CE828 /* WelcomeViewController.swift in Sources */,
D885CFAD2A83C149004CE828 /* OAuthAppRegistrationResponse.swift in Sources */,
D81FE7AD2A84E025004251A3 /* XCAssets+Generated.swift in Sources */,
D885CFA32A838D2D004CE828 /* ConnectToFunkwhaleView.swift in Sources */,
D81FE7922A83DE10004251A3 /* AccessTokenResponse.swift in Sources */,
D885CFB12A83C1C9004CE828 /* FunkwhaleErrors.swift in Sources */,

View File

@ -23,11 +23,13 @@ class AppCoordinator: Coordinator {
let apiClient: APIClient
let keychain: Keychain
let branding: Branding
init(window: UIWindow) {
self.window = window
self.rootViewController = RootViewController()
self.tabBarController = UITabBarController()
self.branding = Branding.shared
keychain = Keychain(service: "pinniped")

View File

@ -0,0 +1,52 @@
//
// Branding.swift
// pinniped-ios
//
// Created by Nathan Mattes on 10.08.23.
//
import UIKit
class Branding {
static let shared = Branding()
init() {
styleNavigationBar()
styleTabBar()
}
private func styleNavigationBar() {
let transparentNavigationBarAppearance = UINavigationBarAppearance()
transparentNavigationBarAppearance.configureWithTransparentBackground()
let opaqueNavigationBarAppearance = UINavigationBarAppearance()
opaqueNavigationBarAppearance.configureWithDefaultBackground()
let appearance = UINavigationBar.appearance()
appearance.tintColor = actionColor
appearance.scrollEdgeAppearance = transparentNavigationBarAppearance
appearance.compactAppearance = opaqueNavigationBarAppearance
appearance.standardAppearance = opaqueNavigationBarAppearance
appearance.compactScrollEdgeAppearance = transparentNavigationBarAppearance
}
private func styleTabBar() {
let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.configureWithDefaultBackground()
let transparentTabBarAppearance = UITabBarAppearance()
transparentTabBarAppearance.configureWithTransparentBackground()
let appearance = UITabBar.appearance()
appearance.tintColor = actionColor
appearance.scrollEdgeAppearance = transparentTabBarAppearance
appearance.standardAppearance = tabBarAppearance
}
//MARK: - Colors
var actionColor: UIColor {
Asset.blue500.color
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xAE",
"green" : "0x7C",
"red" : "0x06"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xBB",
"green" : "0xA2",
"red" : "0x65"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,106 @@
// swiftlint:disable all
// Generated using SwiftGen https://github.com/SwiftGen/SwiftGen
#if os(macOS)
import AppKit
#elseif os(iOS)
import UIKit
#elseif os(tvOS) || os(watchOS)
import UIKit
#endif
#if canImport(SwiftUI)
import SwiftUI
#endif
// Deprecated typealiases
@available(*, deprecated, renamed: "ColorAsset.Color", message: "This typealias will be removed in SwiftGen 7.0")
internal typealias AssetColorTypeAlias = ColorAsset.Color
// swiftlint:disable superfluous_disable_command file_length implicit_return
// MARK: - Asset Catalogs
// swiftlint:disable identifier_name line_length nesting type_body_length type_name
internal enum Asset {
internal static let accentColor = ColorAsset(name: "AccentColor")
internal static let blue500 = ColorAsset(name: "blue-500")
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name
// MARK: - Implementation Details
internal final class ColorAsset {
internal fileprivate(set) var name: String
#if os(macOS)
internal typealias Color = NSColor
#elseif os(iOS) || os(tvOS) || os(watchOS)
internal typealias Color = UIColor
#endif
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *)
internal private(set) lazy var color: Color = {
guard let color = Color(asset: self) else {
fatalError("Unable to load color asset named \(name).")
}
return color
}()
#if os(iOS) || os(tvOS)
@available(iOS 11.0, tvOS 11.0, *)
internal func color(compatibleWith traitCollection: UITraitCollection) -> Color {
let bundle = BundleToken.bundle
guard let color = Color(named: name, in: bundle, compatibleWith: traitCollection) else {
fatalError("Unable to load color asset named \(name).")
}
return color
}
#endif
#if canImport(SwiftUI)
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
internal private(set) lazy var swiftUIColor: SwiftUI.Color = {
SwiftUI.Color(asset: self)
}()
#endif
fileprivate init(name: String) {
self.name = name
}
}
internal extension ColorAsset.Color {
@available(iOS 11.0, tvOS 11.0, watchOS 4.0, macOS 10.13, *)
convenience init?(asset: ColorAsset) {
let bundle = BundleToken.bundle
#if os(iOS) || os(tvOS)
self.init(named: asset.name, in: bundle, compatibleWith: nil)
#elseif os(macOS)
self.init(named: NSColor.Name(asset.name), bundle: bundle)
#elseif os(watchOS)
self.init(named: asset.name)
#endif
}
}
#if canImport(SwiftUI)
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *)
internal extension SwiftUI.Color {
init(asset: ColorAsset) {
let bundle = BundleToken.bundle
self.init(asset.name, bundle: bundle)
}
}
#endif
// swiftlint:disable convenience_type
private final class BundleToken {
static let bundle: Bundle = {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleToken.self)
#endif
}()
}
// swiftlint:enable convenience_type

View File

@ -22,15 +22,15 @@
## This example also shows how to provide additional parameters to your template to customize the output.
## - Especially the `forceProvidesNamespaces: true` param forces to create sub-namespace for each folder/group used in your Asset Catalogs, even the ones without "Provides Namespace". Without this param, SwiftGen only generates sub-namespaces for folders/groups which have the "Provides Namespace" box checked in the Inspector pane.
## - To know which params are supported for a template, use `swiftgen template doc xcassets swift5` to open the template documentation on GitHub.
# xcassets:
# inputs:
# - Main.xcassets
xcassets:
inputs:
- pinniped-ios/pinniped-ios/Resources/Assets.xcassets
# - ProFeatures.xcassets
# outputs:
# - templateName: swift5
outputs:
- templateName: swift5
# params:
# forceProvidesNamespaces: true
# output: XCAssets+Generated.swift
output: pinniped-ios/pinniped-ios/Resources/XCAssets+Generated.swift
## Generate constants for your storyboards and XIBs.