Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
25e01ed
Merge pull request #9 from what3words/beta/MT-674-ocr-redesign
thynguyen248 Jan 17, 2024
f8ae873
[MT-6423] Fix issue scheme lost other properties when using modifier
Jan 17, 2024
e7e5092
Merge pull request #11 from what3words/task/MT-6423-scheme-modifiers
thynguyen248 Jan 17, 2024
cba7709
Merge pull request #10 from what3words/staging
thynguyen248 Jan 18, 2024
665f280
[MT-6484] Add new colors from new design.
Jan 29, 2024
929d40f
updated colours
dave-w3w Jan 29, 2024
d502562
[MT-6484] Add color for error text
Jan 29, 2024
f3506f0
Merge pull request #13 from what3words/task/MT-6484-new-colors
thynguyen248 Jan 29, 2024
e91b0cc
refactored image presets
dave-w3w Jan 31, 2024
86812bf
removed W3WString, core dependancy
dave-w3w Jan 31, 2024
bf759b9
updated icons to for redesign
dave-w3w Feb 2, 2024
f2daf2e
added more icons
dave-w3w Feb 2, 2024
41b48b8
updated to latest design
dave-w3w Feb 9, 2024
cd09a84
Updated to latest figma design
dave-w3w Feb 9, 2024
d93adb3
made some values public
dave-w3w Feb 9, 2024
7718b62
fixed errors cause by moving classes to theme
dave-w3w Feb 9, 2024
7486b13
updated present colours
dave-w3w Feb 14, 2024
b16301a
updated preset colours
dave-w3w Feb 14, 2024
7ad37a5
colour updates and new font funcs
dave-w3w Feb 15, 2024
9202108
[MT-6319] Add SwiftUI Color
khaidow3w Feb 19, 2024
5694081
[MT-6319] add swiftui color to W3WCoreColor
khaidow3w Feb 20, 2024
9ba48a5
Merge pull request #14 from what3words/beta/MT-6319-app-setting-desig…
khaidow3w Feb 20, 2024
9bd3722
merge staging into main
dave-w3w Feb 20, 2024
7c0896e
[MT-6319] Add new outlined icons
khaidow3w Feb 21, 2024
43162b7
Merge pull request #15 from what3words/epic/MT-6319-app-setting-desig…
khaidow3w Feb 21, 2024
25a77a5
Merge pull request #16 from what3words/beta/MT-6319-app-setting-desig…
khaidow3w Feb 22, 2024
8fedcdf
[MT-6319] Add new Color for what3words theme
khaidow3w Feb 22, 2024
d32653f
Merge pull request #18 from what3words/epic/MT-6319-app-setting-desig…
khaidow3w Feb 22, 2024
e770e50
Merge pull request #17 from what3words/staging
khaidow3w Feb 22, 2024
4dc9f13
[MT-6592] Update ocr scheme color and style
Feb 22, 2024
bf5f7b7
Merge pull request #19 from what3words/task/MT-6592-update-on-new-design
thynguyen248 Feb 22, 2024
bdf4d30
[MT-6319] Prevent crash when SFSymbol is not available in some ios ve…
Feb 23, 2024
9334e60
[MT-6319] Add new accessibility icon
Feb 23, 2024
d829795
Merge branch 'staging' into beta/MT-6319-app-setting-design-library
khaidow3w Feb 23, 2024
688e044
[MT-6592] Add light blue color
Feb 23, 2024
fd3db70
Merge pull request #21 from what3words/task/MT-6592-update-on-new-design
thynguyen248 Feb 23, 2024
0b71d58
Merge pull request #20 from what3words/beta/MT-6319-app-setting-desig…
khaidow3w Feb 23, 2024
44a23db
Merge pull request #22 from what3words/staging
dave-w3w Feb 23, 2024
a2fb8dd
fixed secondary colours
dave-w3w Feb 23, 2024
d234ca8
Add visual effect
Feb 25, 2024
7e34e19
Remove UIKit dependency
Feb 26, 2024
29e1506
Add secondary background color
Feb 26, 2024
6c55157
Merge pull request #24 from what3words/task/add-secondary-background-…
thynguyen248 Feb 26, 2024
3402efc
Merge branch 'staging' into task/add-visual-effect
Feb 26, 2024
ce010bf
Remove visual effect extension
Feb 26, 2024
1ace0fe
abstracted visual effect from implentation
dave-w3w Feb 26, 2024
88ec68d
Merge pull request #25 from what3words/task/add-visual-effect-dd
thynguyen248 Feb 28, 2024
06bcf36
Update ocr scheme text color
Feb 28, 2024
951298b
Merge pull request #26 from what3words/task/update-ocr-text-color
thynguyen248 Feb 28, 2024
5b10317
Merge branch 'main' into staging
dave-w3w Feb 28, 2024
0b42487
[MT-6621] Update separator color
Feb 29, 2024
bccf511
Merge pull request #28 from what3words/bug/MT-6621-update-separator-c…
thynguyen248 Feb 29, 2024
676805e
[MT-6319] Add fix to mirrored file W3WImage
Feb 29, 2024
435e1cd
Merge pull request #29 from what3words/beta/MT-6319-app-setting-desig…
khaidow3w Feb 29, 2024
d5728e3
[MT-6614] Add w3w logo with text
Mar 1, 2024
a80c288
Merge pull request #31 from what3words/bug/MT-6614-add-w3w-logo
thynguyen248 Mar 1, 2024
a943025
add bigger accessibility icon
Mar 1, 2024
ae26a46
Add configuration for w3wimage
Mar 5, 2024
fd92e47
Merge pull request #33 from what3words/fix/bigger-accessibility-icon
khaidow3w Mar 5, 2024
7623de9
Update warning icon
Mar 14, 2024
8e7b678
Merge pull request #35 from what3words/task/update-warning-icon
thynguyen248 Mar 15, 2024
0bee926
fixed colours, added symbol
dave-w3w Mar 20, 2024
4d56f56
updates/fixes to latest figma colours
dave-w3w Mar 21, 2024
f1391fd
added core prefix to primitives from core design system
dave-w3w Mar 26, 2024
eef1294
Merge pull request #37 from what3words/task/MT-6660-symbols-colors-up…
dave-w3w Mar 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions Package.resolved

This file was deleted.

11 changes: 3 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ import PackageDescription

let package = Package(
name: "w3w-swift-themes",

products: [.library(name: "W3WSwiftThemes", targets: ["W3WSwiftThemes"])],

dependencies: [.package(url: "git@github.com:what3words/w3w-swift-core.git", branch: "main")],

targets: [
.target(
name: "W3WSwiftThemes",
dependencies: [.product(name: "W3WSwiftCore", package: "w3w-swift-core")]
),

.testTarget(name: "w3w-swift-themesTests", dependencies: ["W3WSwiftThemes"])
.target(name: "W3WSwiftThemes", resources: [.process("Resources")]),
.testTarget(name: "w3w-swift-themesTests", dependencies: ["W3WSwiftThemes"])
]
)
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# <img valign='top' src="https://what3words.com/assets/images/w3w_square_red.png" width="64" height="64" alt="what3words">&nbsp;w3w-swift-themes

# Overview

This contains all colour and style definitions

### Themes

A `W3WTheme` conatins all colour or style information for an app or a component. It is bascially a container of `W3WScheme`. It holds a dictionary of named `W3WScheme`. These schemes are keyed by things like `base`, `textFeilds`, `cells`, `labels`, and so on. These schemes are then to be applied to the part fo the app or component that corresponds.

### Schemes

A `W3WScheme` holds a `W3WColors` and a `W3WStyles`. It is intended to be all the colour and style information needed for a particular view.

### Styles

A `W3WStyles` struct holds various styling information for a particular view. This includes things like: border, corner radius, shadow, fonts, text alignment, padding, separator, row height, line thickness, and so on.


### Colors

A `W3WColors` struct holds vaious colours for a particular view. This includes things like: foreground, background, tint, secondary, brand, highlight, border, separator, shadow, placeholder, success, error, header, line, and so on.

The colours that are held by `W3WColors` are `W3WColor`.

### Color

A `W3WColor` struct holds two colours. A `light` and `dark` value. These are implemented as a dictionary keyed by `light` and `dark` in case new colour modes are ever introduced for any Apple platform.

These two values are of type `W3WCoreColor`.

### Core Color

A `W3WCoreColor` struct holds a single colour in the form of four Float values: red, green, blue, & alpha.

This is used as opposed to the built in operating system provided colours because this is a multi-operating system design library. Apple's various UI systems use NScolor, UIColor, CGColor, and Color. Not all of these color types are available in a particular OS/UI system. A neutral color definition was therefore required for interoperability.

There are constructors that take NScolor, UIColor, CGColor, and Color, and these objects can produce them as well with the cgColor, suColor, uiColor, and nsColor computed variables.

### Predefined Values

In the `Presets' directory there are a number of predefined values for colours and styles.





35 changes: 34 additions & 1 deletion Sources/W3WSwiftThemes/Extensions/UIColorExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension UIColor {
/// what3words extension to get a W3WColor object from a UIColor, defined in the W3WSwiftDesign module
public var w3wColor: W3WColor {
get {
return W3WColor(uiColor: self)
return W3WColor(uiColor: light(), dark: dark()) // return W3WColor(uiColor: self)
}
}

Expand All @@ -27,6 +27,39 @@ extension UIColor {
}
}


/// if this UIColor is a UI element color (semantic color) then get the subcolor for light mode otherwise return self
func light() -> UIColor {
if #available(iOS 13, *) {
return self.colorFor(mode: .light)
} else {
return self
}
}


/// if this UIColor is a UI element color (semantic color) then get the subcolor for dark mode otherwise return self
func dark() -> UIColor {
if #available(iOS 13, *) {
return self.colorFor(mode: .dark)
} else {
return self
}
}


/// if this UIColor is a UI element color (semantic color) then find the subcolor for light or dark mode
/// - Parameters:
/// - mode: specify .light or .dark
func colorFor(mode: UIUserInterfaceStyle) -> UIColor {
if #available(iOS 13, *) {
return self.resolvedColor(with: UITraitCollection(userInterfaceStyle: mode))
} else {
return self
}
}


}

#endif
141 changes: 70 additions & 71 deletions Sources/W3WSwiftThemes/Extensions/UIViewExtension.swift
Original file line number Diff line number Diff line change
@@ -1,76 +1,75 @@
////
//// File.swift
////
////
//// Created by Dave Duprey on 19/08/2023.
////
//
// File.swift
//#if canImport(UIKit)
//import UIKit
//
//
//// private extension to easily color and style UIViews
//public extension UIView {
//
//
// func apply(scheme: W3WScheme?) {
// if let colors = scheme?.colors {
// apply(colors: colors)
// }
//
// if let styles = scheme?.styles {
// apply(styles: styles)
// }
// }
//
//
// func apply(colors: W3WColors?) {
// if let c = colors?.background {
// backgroundColor = c.current.uiColor
// }
//
// if let t = colors?.tint {
// tintColor = t.current.uiColor
// }
//
// if let b = colors?.border {
// layer.borderColor = b.current.cgColor
// }
//
// if let s = colors?.shadow {
// layer.shadowColor = s.current.cgColor
// }
//
// // special case to get inside a searchcontroller
//// if let s = self as? UISearchBar {
//// if let background = colors[.textFields].background {
//// if #available(iOS 13.0, *) {
//// s.searchTextField.backgroundColor = background.current.uiColor
//// } else {
//// s.backgroundColor = background.current.uiColor
//// }
//// }
//// }
// }
//
//
// func apply(styles: W3WStyles?) {
// if let border = styles?.border?.value {
// layer.borderWidth = border
// }
//
// Created by Dave Duprey on 19/08/2023.
// if let cornerRadius = styles?.cornerRadius?.value {
// layer.cornerRadius = cornerRadius
// }
//

#if canImport(UIKit)
import UIKit


// private extension to easily color and style UIViews
public extension UIView {


func apply(scheme: W3WScheme?) {
if let colors = scheme?.colors {
apply(colors: colors)
}

if let styles = scheme?.styles {
apply(styles: styles)
}
}


func apply(colors: W3WColors?) {
if let c = colors?.background {
backgroundColor = c.current.uiColor
}

if let t = colors?.tint {
tintColor = t.current.uiColor
}

if let b = colors?.border {
layer.borderColor = b.current.cgColor
}

if let s = colors?.shadow {
layer.shadowColor = s.current.cgColor
}

// special case to get inside a searchcontroller
// if let s = self as? UISearchBar {
// if let background = colors[.textFields].background {
// if #available(iOS 13.0, *) {
// s.searchTextField.backgroundColor = background.current.uiColor
// } else {
// s.backgroundColor = background.current.uiColor
// }
// }
// if let shadow = styles?.shadow {
// layer.shadowOpacity = Float(shadow.opacity)
// layer.shadowOffset = CGSize(width: shadow.offset, height: shadow.offset)
// layer.shadowRadius = shadow.radius
// }
}


func apply(styles: W3WStyles?) {
if let border = styles?.border?.value {
layer.borderWidth = border
}

if let cornerRadius = styles?.cornerRadius?.value {
layer.cornerRadius = cornerRadius
}

if let shadow = styles?.shadow {
layer.shadowOpacity = Float(shadow.opacity)
layer.shadowOffset = CGSize(width: shadow.offset, height: shadow.offset)
layer.shadowRadius = shadow.radius
}
}

}


#endif
// }
//
//}
//
//#endif
Loading