Skip to content

Commit

Permalink
Generate Standard Style types
Browse files Browse the repository at this point in the history
  • Loading branch information
persidskiy committed Oct 7, 2024
1 parent 7c56c6e commit 05420d4
Show file tree
Hide file tree
Showing 12 changed files with 325 additions and 158 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ repos:
- id: trailing-whitespace
exclude: LICENSE.md
- id: end-of-file-fixer
exclude: ".*.list"
- id: check-yaml
- id: check-json
exclude: .vscode/.*.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ struct StandardStyleLocationsExample: View {
.standard(
theme: model.theme,
lightPreset: model.lightPreset,
font: model.font,
showPointOfInterestLabels: model.poi,
showTransitLabels: model.transitLabels,
showPlaceLabels: model.placeLabels,
Expand All @@ -29,6 +30,7 @@ struct StandardStyleLocationsExample: View {
case .standardSatellite:
.standardSatellite(
lightPreset: model.lightPreset,
font: model.font,
showPointOfInterestLabels: model.poi,
showTransitLabels: model.transitLabels,
showPlaceLabels: model.placeLabels,
Expand Down Expand Up @@ -82,6 +84,7 @@ class StandardStyleLocationsModel: ObservableObject {
@Published var viewport: Viewport = Location.all.first!.viewport
@Published var style: Style = .standard
@Published var theme: StandardTheme = .default
@Published var font: StandardFont = .dinPro

enum Style {
case standard
Expand Down Expand Up @@ -143,6 +146,38 @@ struct StandardStyleLocationsSettings: View {
}
}

HStack {
Text("Font")
Spacer()
Picker("Font", selection: $model.font) {
Text("Alegreya").tag(StandardFont.alegreya)
Text("Alegreya SC").tag(StandardFont.alegreyaSc)
Text("Asap").tag(StandardFont.asap)
Text("Barlow").tag(StandardFont.barlow)
Text("DIN Pro").tag(StandardFont.dinPro)
Text("EB Garamond").tag(StandardFont.ebGaramond)
Text("Faustina").tag(StandardFont.faustina)
Text("Frank Ruhl Libre").tag(StandardFont.frankRuhlLibre)
Text("Heebo").tag(StandardFont.heebo)
Text("Inter").tag(StandardFont.inter)
Text("Lato").tag(StandardFont.lato)
Text("League Mono").tag(StandardFont.leagueMono)
Text("Montserrat").tag(StandardFont.montserrat)
Text("Manrope").tag(StandardFont.manrope)
Text("Noto Sans CJK JP").tag(StandardFont.notoSansCjkJp)
Text("Open Sans").tag(StandardFont.openSans)
Text("Poppins").tag(StandardFont.poppins)
Text("Raleway").tag(StandardFont.raleway)
Text("Roboto").tag(StandardFont.roboto)
Text("Roboto Mono").tag(StandardFont.robotoMono)
Text("Rubik").tag(StandardFont.rubik)
Text("Source Code Pro").tag(StandardFont.sourceCodePro)
Text("Source Sans Pro").tag(StandardFont.sourceSansPro)
Text("Spectral").tag(StandardFont.spectral)
Text("Ubuntu").tag(StandardFont.ubuntu)
}.pickerStyle(.menu)
}

ScrollView(.horizontal, showsIndicators: false) {
HStack {
Text("Labels")
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ Mapbox welcomes participation and contributions from everyone.

## main

* Generate `MapStyle.standard` and `MapStyle.standardSatellite` from the style specification. Added the new `StandardFont` type to represent the font family in these configurations. If you used a string variable, update your code:
```swift
// Old:
Map().mapStyle(.standard(font: fontValue))
/// New:
Map().mapStyle(.standard(font: StandardFont(rawValue: fontValue)))
Map().mapStyle(.standard(font: .lato))
```


## 11.7.0 - 26 September, 2024

* Fix the bug where displaying ViewAnnotation and setting a feature state simultaneously could result in an unapplied feature state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- ``LightType``
- ``StandardLightPreset``
- ``StandardTheme``
- ``StandardFont``
- ``StyleProjection``
- ``StyleProjectionName``
- ``CancelError``
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extension JSONObject {
mutating func encode(key: String, value: Bool?) {
if let value {
self[key] = .boolean(value)
}
}

mutating func encode<T>(key: String, value: T?) where T: RawRepresentable, T.RawValue == String {
if let value {
self[key] = .string(value.rawValue)
}
}
}
161 changes: 161 additions & 0 deletions Sources/MapboxMaps/Style/Generated/MapStyle+Standard.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 05420d4

Please sign in to comment.