-
Notifications
You must be signed in to change notification settings - Fork 10
MOB-65231: Доработка для SF Symbols #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: RDS-831
Are you sure you want to change the base?
Changes from all commits
ba1801e
44f11a1
d7b7b9e
fdd951c
1fb7641
90655af
a1e582d
1be62e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import Foundation | ||
|
|
||
| enum SymbolRenderingMode: String, Codable { | ||
|
|
||
| case template | ||
| case multicolor | ||
| case hierarchical | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import Foundation | ||
|
|
||
| struct SFSymbolLayer { | ||
|
|
||
| let index: Int | ||
| let role: SFSymbolRole | ||
| let paths: [SFSymbolPathData] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import Foundation | ||
|
|
||
| struct SFSymbolPathData { | ||
|
|
||
| // Данные пути, уже переведённые в координатное пространство SF Symbols. | ||
| let data: String | ||
| let fillRule: String? | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import Foundation | ||
|
|
||
| /// Роль пути в палитре слоёв. Определяется по id пути, а если его нет - по заливке: | ||
| /// чёрная заливка из Figma даёт primary, любая другая - secondary. | ||
| enum SFSymbolRole: String { | ||
|
|
||
| case primary | ||
| case secondary | ||
| case tertiary | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import Foundation | ||
|
|
||
| /// Размер корневого элемента `<svg>`, который Figma выгружает равным боксу компонента. | ||
| /// Геометрия SF Symbols строится именно от этого бокса, а не от границ видимых путей, | ||
| /// чтобы сохранить заложенные в Figma отступы. | ||
| struct SVGCanvas: Equatable { | ||
|
|
||
| let width: Double | ||
| let height: Double | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import Foundation | ||
|
|
||
| enum SVGColor: Equatable { | ||
|
|
||
| case black | ||
| case other(String) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import Foundation | ||
|
|
||
| struct SVGGroupContext { | ||
|
|
||
| let id: String? | ||
| let fill: SVGColor? | ||
| let transform: String? | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import Foundation | ||
|
|
||
| // Всё, что нужно SVG-шаблону, чтобы разложить рисунок из Figma в координатах SF Symbols. | ||
| struct SVGImageToken { | ||
|
|
||
| let name: String | ||
| let opticalSize: Int | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А это Int почему? Не должно быть тоже Double или Width/Height?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. можно заменить, да, скорее всего Int тут, потому что изначально размеры 16х16 и 24х24 у икононок |
||
| let designWidth: Double | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Там выше была моделька размера, а тут раздельные проперти.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. погляжу |
||
| let designHeight: Double | ||
| let layers: [SFSymbolLayer] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import Foundation | ||
|
|
||
| enum SVGNumber { | ||
|
|
||
| /// Форматирует число для атрибутов SVG: до шести знаков после запятой, без хвостовых нулей | ||
| /// и без отрицательного нуля. | ||
| static func string(from value: Double) -> String { | ||
| var text = String(format: "%.6f", value) | ||
|
|
||
| if text.contains(".") { | ||
| while text.hasSuffix("0") { | ||
| text.removeLast() | ||
| } | ||
|
|
||
| if text.hasSuffix(".") { | ||
| text.removeLast() | ||
| } | ||
| } | ||
|
|
||
| return text == "-0" ? "0" : text | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.