-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Basic SharedUI Design system - WRCore package for shared utils and core setup
- Loading branch information
Showing
53 changed files
with
605 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// swift-tools-version: 5.10 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SharedUI", | ||
platforms: [ | ||
.iOS(.v15), | ||
], | ||
products: [ | ||
.library( | ||
name: "SharedUI", | ||
targets: ["SharedUI"] | ||
), | ||
], | ||
targets: [ | ||
.target( | ||
name: "SharedUI", | ||
resources: [ | ||
.process("Resources"), | ||
] | ||
), | ||
.testTarget( | ||
name: "SharedUITests", | ||
dependencies: ["SharedUI"] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import SwiftUI | ||
|
||
public extension Color { | ||
static var main: Color { | ||
Color(.main) | ||
} | ||
|
||
static var accent: Color { | ||
Color(.accent) | ||
} | ||
|
||
/// black in light mode, white in dark mode | ||
static var blackWhite: Color { | ||
Color(.blackWhite) | ||
} | ||
|
||
/// white in light mode, black in dark mode | ||
static var whiteBlack: Color { | ||
Color(.whiteBlack) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import SwiftUI | ||
|
||
public enum WrFont { | ||
case h1 | ||
case h2 | ||
case h3 | ||
case h4 | ||
case body | ||
case caption1 | ||
case caption2 | ||
|
||
var baseSize: CGFloat { | ||
switch self { | ||
case .h1: | ||
56 | ||
case .h2: | ||
48 | ||
case .h3: | ||
32 | ||
case .h4: | ||
24 | ||
case .body: | ||
16 | ||
case .caption1: | ||
14 | ||
case .caption2: | ||
12 | ||
} | ||
} | ||
} | ||
|
||
private struct WrTextStyle: ViewModifier { | ||
let fontStyle: WrFont | ||
|
||
@ScaledMetric | ||
var fontSize: CGFloat | ||
|
||
var font: Font { | ||
.system(size: fontSize) | ||
} | ||
|
||
init(fontStyle: WrFont) { | ||
self.fontStyle = fontStyle | ||
_fontSize = ScaledMetric(wrappedValue: fontStyle.baseSize) | ||
} | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.font(font) | ||
} | ||
} | ||
|
||
public extension View { | ||
func textStyle(_ font: WrFont) -> some View { | ||
modifier(WrTextStyle(fontStyle: font)) | ||
} | ||
} | ||
|
||
#Preview { | ||
ScrollView { | ||
VStack { | ||
Text("h1") | ||
.textStyle(.h1) | ||
|
||
Text("h2") | ||
.textStyle(.h2) | ||
|
||
Text("h3") | ||
.textStyle(.h3) | ||
|
||
Text("h4") | ||
.textStyle(.h4) | ||
|
||
Text("body") | ||
.textStyle(.body) | ||
|
||
Text("caption1") | ||
.textStyle(.caption1) | ||
|
||
Text("caption2") | ||
.textStyle(.caption2) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import SwiftUI | ||
|
||
public extension Image { | ||
static var logoRounded: Image { | ||
Image(.logoRounded) | ||
} | ||
|
||
static var logoLaunch: Image { | ||
Image(.logoLaunch) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
Modules/SharedUI/Sources/SharedUI/Resources/Colors.xcassets/main.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0xFF", | ||
"green" : "0xBC", | ||
"red" : "0xAC" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0x88", | ||
"green" : "0x4C", | ||
"red" : "0x40" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...les/SharedUI/Sources/SharedUI/Resources/Colors.xcassets/whiteBlack.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "1.000", | ||
"green" : "1.000", | ||
"red" : "1.000" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.000", | ||
"green" : "0.000", | ||
"red" : "0.000" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import SwiftUI | ||
|
||
private struct SharedUIExample: View { | ||
var body: some View { | ||
VStack(alignment: .leading) { | ||
Text("h1") | ||
Text("h2") | ||
Text("h3") | ||
Text("h4") | ||
Text("h5") | ||
Text("h6") | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.padding() | ||
} | ||
} | ||
|
||
#Preview { | ||
SharedUIExample() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@testable import SharedUI | ||
import XCTest | ||
|
||
final class SharedUITests: XCTestCase { | ||
func testExample() throws { | ||
// XCTest Documentation | ||
// https://developer.apple.com/documentation/xctest | ||
|
||
// Defining Test Cases and Test Methods | ||
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// swift-tools-version: 5.10 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "WRCore", | ||
platforms: [ | ||
.iOS(.v15), | ||
], | ||
products: [ | ||
.library( | ||
name: "WRCore", | ||
targets: ["WRCore"] | ||
), | ||
], | ||
dependencies: [ | ||
.package(path: "../SharedUI"), | ||
.package(url: "https://github.com/DatepollSystems/WaiterRobot-Shared-Android.git", from: "1.6.1"), | ||
], | ||
targets: [ | ||
.target( | ||
name: "WRCore", | ||
dependencies: [ | ||
.product(name: "SharedUI", package: "SharedUI"), | ||
.product(name: "shared", package: "WaiterRobot-Shared-Android"), | ||
] | ||
), | ||
.testTarget( | ||
name: "WRCoreTests", | ||
dependencies: ["WRCore"] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Foundation | ||
import shared | ||
import UIKit | ||
|
||
public var koin: IosKoinComponent { IosKoinComponent.shared } | ||
|
||
public var localize: shared.L.Companion { shared.L.Companion.shared } | ||
|
||
public enum WRCore { | ||
/// Setup of frameworks and all the other related stuff which is needed everywhere in the app | ||
public static func setup() { | ||
print("started app setup") | ||
var appVersion = readFromInfoPlist(withKey: "CFBundleShortVersionString") | ||
let versionSuffix = readFromInfoPlist(withKey: "VERSION_SUFFIX") | ||
if !versionSuffix.isEmpty { | ||
appVersion += "-\(versionSuffix)" | ||
} | ||
|
||
CommonApp.shared.doInit( | ||
appVersion: appVersion, | ||
appBuild: Int32(readFromInfoPlist(withKey: "CFBundleVersion"))!, | ||
phoneModel: UIDevice.current.model, | ||
os: OS.Ios(version: UIDevice.current.systemVersion), | ||
allowedHostsCsv: readFromInfoPlist(withKey: "ALLOWED_HOSTS"), | ||
stripeProvider: nil | ||
) | ||
|
||
KoinKt.doInitKoinIos() | ||
let logger = koin.logger(tag: "AppDelegate") | ||
logger.d { "initialized Koin" } | ||
|
||
KMMResourcesLocalizationKt.localizationBundle = Bundle(for: shared.L.self) | ||
logger.d { "initialized localization bundle" } | ||
print("finished app setup") | ||
} | ||
|
||
private static func readFromInfoPlist(withKey key: String) -> String { | ||
guard let value = Bundle.main.infoDictionary?[key] as? String else { | ||
fatalError("Could not find key '\(key)' in info.plist file.") | ||
} | ||
|
||
return value | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
WaiterRobot/Core/KermitLoggerExtension.swift → ...ources/WRCore/KermitLoggerExtension.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Foundation | ||
import shared | ||
|
||
public extension Array where Element: AnyObject { | ||
init(_ kotlinArray: KotlinArray<Element>) { | ||
self.init() | ||
let iterator = kotlinArray.iterator() | ||
while iterator.hasNext() { | ||
append(iterator.next() as! Element) | ||
} | ||
} | ||
} |
Oops, something went wrong.