Skip to content

Commit

Permalink
Merge pull request #51 from SchweizerischeBundesbahnen/feature/sbbIco…
Browse files Browse the repository at this point in the history
…ns_enum

Feature/sbb icons enum
  • Loading branch information
georgiosantoniadis authored Mar 24, 2023
2 parents bb16578 + 357913b commit e4f34d1
Show file tree
Hide file tree
Showing 7,608 changed files with 76,755 additions and 7,333 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SBBDesignSystemMobileSwiftUI_SBBDesignSystemMobileSwiftUI"
BuildableName = "SBBDesignSystemMobileSwiftUI_SBBDesignSystemMobileSwiftUI"
BlueprintName = "SBBDesignSystemMobileSwiftUI_SBBDesignSystemMobileSwiftUI"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SBBDesignSystemMobileSwiftUI"
BuildableName = "SBBDesignSystemMobileSwiftUI"
BlueprintName = "SBBDesignSystemMobileSwiftUI"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "SBBDesignSystemMobileSwiftUI_SBBDesignSystemMobileSwiftUI"
BuildableName = "SBBDesignSystemMobileSwiftUI_SBBDesignSystemMobileSwiftUI"
BlueprintName = "SBBDesignSystemMobileSwiftUI_SBBDesignSystemMobileSwiftUI"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
34 changes: 34 additions & 0 deletions HowTo_ImportSBBIcons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Importing SBB Icons into the Design Library

## Introduction

This library offers all icons you can find in the official https://digital.sbb.ch/de/brand_elemente site.

There are three different types of icons:
* SBB-Icons: https://digital.sbb.ch/de/brand_elemente/icons
* SBB-Timetable-Icons: https://digital.sbb.ch/de/brand_elemente/fahrplan-icons
* SBB-Pictograms: https://digital.sbb.ch/de/brand_elemente/piktogramme

In general, SBB-Icons are present in three different sizes (small, medium, large), meanwhile SBB-Timetable-Icons and SBB-Pictograms have each only one size. Also, you are allowed to change the colour of some of the above icons, and some of them not. In general you can say, that only the SBB-Icons can change their color. There is a list indicating what icons can change it.

## Importing SBB Icons

### SBB-Icons and SBB-Timetable-Icons:
* Download the repo at: https://github.com/sbb-design-systems/sbb-icons/
* change folder name `icons` to `SBB Icons`
* Replace the content of the file `index.json` with the content of the source file `Resources/SBBIconsIndex.json`. Then remove the `index.json`
* Remove old `SBB Icons` of the Assets.xcassets
* Move the newly downloaded and renamed `SBB Icons` folder into the Assets.xcassets
* Select every icon in the Assets and change from "Individual Scales" to "Single Scale"

Note that the `Resources/SBBIconsIndex.json` indicate, whether the icon is able to change color or not.

### SBB-Pictograms:
* Download the repo at: https://github.com/sbb-design-systems/picto-library/
* change folder name `pictos` to `SBB Pictos`
* Remove old `SBB Pictos` of the Assets.xcassets
* Move the newly downloaded and renamed `SBB Pictos` folder into the Assets.xcassets
* Select every icon in the Assets and change from "Individual Scales" to "Single Scale"

Building the Lib should now invoke the `generate_enum_file.swift` script, which generates the `Resources/SBBIconName.swift` file containing an enum with all the icons of the Assets.xcassets.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Generally speaking, we are welcoming contributions improving existing UI element

General instructions on _how_ to contribute can be found under [Contributing](Contributing.md).

## Missing SBB Icons?

Tell us! How to do it is described under [How to import SBB Icons](HowTo_ImportSBBIcons.md).

## Authors

* **Brunner Nicolas**
Expand Down
13 changes: 13 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Release Notes SBBDesignSystemMobileSwiftUI for iOS & SwiftUI

## v1.0.3 - 21 March 2023

### Improvements
* re-import the newest SBB Icons / SBB Pictos
* All SBB Icons / SBB Pictos are now present inside the "SBBIconName.swift" enum. You can create an SBB Image with the `init(sbbIcon: SBBIcon)` initializer

### Deprecations
* Initializing an SBB Image with `init(sbbName: String)` or `init(sbbName: String, size: SBBIconSize)` is deprecated and will be removed in a future version

### Breaking changes
* Attention: certain icons have been renamed. Please check your code whether the used icon-string exists. Better: migrate to the new `init(sbbIcon: SBBIcon)` initializer


## V1.0.2 - 08 March 2023

### Features
Expand Down
41 changes: 40 additions & 1 deletion SBBDesignSystemMobileSwiftUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -25,6 +25,9 @@
00FB8195278ED50600F07D30 /* TabBarShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00FB8194278ED50600F07D30 /* TabBarShape.swift */; };
00FB8197278ED55E00F07D30 /* TabBarEntryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00FB8196278ED55E00F07D30 /* TabBarEntryView.swift */; };
00FB819B278ED67F00F07D30 /* TabBarEntryViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00FB819A278ED67F00F07D30 /* TabBarEntryViewModifier.swift */; };
2D5B275B29C994C300B3CC88 /* SBBIconsIndex.json in Resources */ = {isa = PBXBuildFile; fileRef = 2D5B275A29C994C300B3CC88 /* SBBIconsIndex.json */; };
2D5B275D29C99D1800B3CC88 /* SBBIconsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D5B275C29C99D1800B3CC88 /* SBBIconsHelper.swift */; };
2D5B276829C9DD4F00B3CC88 /* HowTo_ImportSBBIcons.md in Resources */ = {isa = PBXBuildFile; fileRef = 2D5B276729C9DD4F00B3CC88 /* HowTo_ImportSBBIcons.md */; };
2D804E6823D9D0DF00CC9C0C /* SBBMobileDesignSystemSwiftUI.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D804E5A23D9D0DF00CC9C0C /* SBBMobileDesignSystemSwiftUI.h */; settings = {ATTRIBUTES = (Public, ); }; };
2D804E7823D9D16000CC9C0C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D804E7723D9D16000CC9C0C /* AppDelegate.swift */; };
2D804E7A23D9D16000CC9C0C /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D804E7923D9D16000CC9C0C /* SceneDelegate.swift */; };
Expand All @@ -42,6 +45,7 @@
2DCEC9022539E34A008EDD15 /* TypographyUIKitView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DCEC9012539E34A008EDD15 /* TypographyUIKitView.swift */; };
2DCEC918253D83B7008EDD15 /* SBBColorName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DCEC917253D83B7008EDD15 /* SBBColorName.swift */; };
2DCEC937253EC7F4008EDD15 /* SBBColorNameInternal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DCEC936253EC7F4008EDD15 /* SBBColorNameInternal.swift */; };
2DD29DFC29BCB0900083A8A0 /* SBBIconName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DD29DFB29BCB0900083A8A0 /* SBBIconName.swift */; };
7C0DDFDA25A6DBA9009BB31D /* SliderExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C0DDFD925A6DBA9009BB31D /* SliderExtension.swift */; };
7C0DDFE625A6DFA6009BB31D /* SliderDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C0DDFE525A6DFA6009BB31D /* SliderDemo.swift */; };
7C0DDFEC25A6F587009BB31D /* TextFieldViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C0DDFEB25A6F587009BB31D /* TextFieldViewModel.swift */; };
Expand Down Expand Up @@ -242,6 +246,9 @@
00FB8194278ED50600F07D30 /* TabBarShape.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarShape.swift; sourceTree = "<group>"; };
00FB8196278ED55E00F07D30 /* TabBarEntryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarEntryView.swift; sourceTree = "<group>"; };
00FB819A278ED67F00F07D30 /* TabBarEntryViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarEntryViewModifier.swift; sourceTree = "<group>"; };
2D5B275A29C994C300B3CC88 /* SBBIconsIndex.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = SBBIconsIndex.json; sourceTree = "<group>"; };
2D5B275C29C99D1800B3CC88 /* SBBIconsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SBBIconsHelper.swift; sourceTree = "<group>"; };
2D5B276729C9DD4F00B3CC88 /* HowTo_ImportSBBIcons.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = HowTo_ImportSBBIcons.md; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.markdown; };
2D804E5723D9D0DF00CC9C0C /* SBBDesignSystemMobileSwiftUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SBBDesignSystemMobileSwiftUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2D804E5A23D9D0DF00CC9C0C /* SBBMobileDesignSystemSwiftUI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SBBMobileDesignSystemSwiftUI.h; sourceTree = "<group>"; };
2D804E5B23D9D0DF00CC9C0C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -263,6 +270,7 @@
2DCEC9012539E34A008EDD15 /* TypographyUIKitView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypographyUIKitView.swift; sourceTree = "<group>"; };
2DCEC917253D83B7008EDD15 /* SBBColorName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SBBColorName.swift; sourceTree = "<group>"; };
2DCEC936253EC7F4008EDD15 /* SBBColorNameInternal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SBBColorNameInternal.swift; sourceTree = "<group>"; };
2DD29DFB29BCB0900083A8A0 /* SBBIconName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SBBIconName.swift; sourceTree = "<group>"; };
7C0DDFD925A6DBA9009BB31D /* SliderExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SliderExtension.swift; sourceTree = "<group>"; };
7C0DDFE525A6DFA6009BB31D /* SliderDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SliderDemo.swift; sourceTree = "<group>"; };
7C0DDFEB25A6F587009BB31D /* TextFieldViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -514,6 +522,7 @@
7C2B7E7223DAC4FD0012CF62 /* README.md */,
7CC4B00F276A19E700B3BC46 /* Contributing.md */,
7C2B7E7323DAC4FD0012CF62 /* ReleaseNotes.md */,
2D5B276729C9DD4F00B3CC88 /* HowTo_ImportSBBIcons.md */,
7C77C2D6276B233000AC8157 /* LICENSE */,
F8882F2C27AD37E200396FC7 /* ci_scripts */,
7C77C2D2276B155300AC8157 /* LICENSES */,
Expand Down Expand Up @@ -612,6 +621,8 @@
2D804EAE23D9D3BE00CC9C0C /* Resources */ = {
isa = PBXGroup;
children = (
2D5B275A29C994C300B3CC88 /* SBBIconsIndex.json */,
2DD29DFB29BCB0900083A8A0 /* SBBIconName.swift */,
2D804EAF23D9D3E600CC9C0C /* Assets.xcassets */,
7C9C46DD24CB1ACE00C22E97 /* Preview Content */,
7CDFFD8323E9C3C000250717 /* Localizable.strings */,
Expand Down Expand Up @@ -863,6 +874,7 @@
A74C8B722437634500BF26E3 /* ArrayBuilder.swift */,
7CAFE98523DECD9B001ADBE8 /* Helper.swift */,
7CAC69F925CAE73F003CF54E /* SizePreferenceKey.swift */,
2D5B275C29C99D1800B3CC88 /* SBBIconsHelper.swift */,
);
path = Helper;
sourceTree = "<group>";
Expand Down Expand Up @@ -967,6 +979,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 2D804E6B23D9D0DF00CC9C0C /* Build configuration list for PBXNativeTarget "SBBDesignSystemMobileSwiftUI" */;
buildPhases = (
2D497EA929BB88F9009DF93F /* [custom] Create Image Enum File */,
2D804E5223D9D0DF00CC9C0C /* Headers */,
2D804E5323D9D0DF00CC9C0C /* Sources */,
2D804E5423D9D0DF00CC9C0C /* Frameworks */,
Expand Down Expand Up @@ -1080,8 +1093,10 @@
92B4A0BC25592572005F4F06 /* sbbweb-condensed-bold-reduce.ttf in Resources */,
7C9C46DF24CB1AED00C22E97 /* Preview Assets.xcassets in Resources */,
92B4A0B925592572005F4F06 /* sbbweb-bold-reduce.ttf in Resources */,
2D5B276829C9DD4F00B3CC88 /* HowTo_ImportSBBIcons.md in Resources */,
92B4A0B725592572005F4F06 /* sbbweb-thin-reduce.ttf in Resources */,
2D804EB023D9D3E600CC9C0C /* Assets.xcassets in Resources */,
2D5B275B29C994C300B3CC88 /* SBBIconsIndex.json in Resources */,
92B4A0B825592572005F4F06 /* sbbweb-ultralight-reduce.ttf in Resources */,
92B4A0BB25592572005F4F06 /* sbbweb-italic-reduce.ttf in Resources */,
92B4A0B625592572005F4F06 /* sbbweb-light-reduce.ttf in Resources */,
Expand Down Expand Up @@ -1113,6 +1128,28 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2D497EA929BB88F9009DF93F /* [custom] Create Image Enum File */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "[custom] Create Image Enum File";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n# Type a script or drag a script file from your workspace to insert its path.\nxcrun --sdk macosx \"$TOOLCHAIN_DIR/usr/bin/\"swift \"$PROJECT_DIR\"/SBBDesignSystemMobileSwiftUI/Scripts/generate_enum_file.swift\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
2D804E5323D9D0DF00CC9C0C /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand All @@ -1128,6 +1165,7 @@
7C71655E246D6155009C3FB1 /* FontExtension.swift in Sources */,
005DC8DD279B12D2009C5CEA /* FakeTabBarParameters.swift in Sources */,
005DC8D0279AA42B009C5CEA /* TabButtonRowView.swift in Sources */,
2DD29DFC29BCB0900083A8A0 /* SBBIconName.swift in Sources */,
A7DE2069243C5A7900557F4D /* SBBPrimaryButtonStyle.swift in Sources */,
92B4A0C125592694005F4F06 /* SBBBundle.swift in Sources */,
7C624895247E2ACB00F54C9D /* SBBListItem.swift in Sources */,
Expand Down Expand Up @@ -1159,6 +1197,7 @@
7CAFE99F23DEE515001ADBE8 /* SBBAppearance.swift in Sources */,
7C106D2E25DAA74D00B89ECD /* SBBToastContainerViewModifier.swift in Sources */,
A706C156243715060029BD8D /* SBBCheckBox.swift in Sources */,
2D5B275D29C99D1800B3CC88 /* SBBIconsHelper.swift in Sources */,
7C28871E24BF2B1200EDBD27 /* FakeSBBOnboardingTitleViews.swift in Sources */,
7C2DFE3C25B5BF7900030342 /* SBBDialogue.swift in Sources */,
7C595E5325A5FBCE0015B0FC /* SBBRadioButton.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Note that this frameworks contains many ViewModifiers in form of View Extensions
* View.sbbScreenPadding(): Applies SBB specific padding to a View (typically a View covering the entire screen).
* View.sbbEnvironmentBanner(banner: ``SBBEnvironmentBanner``): Applies a banner (typically to a NavigationBar) indicating the app's environment.
* Color.sbbColor(name: ``SBBColorName``): Returns the specified SBB color.
* Image(sbbName: String, size: ``SBBIconSize``): Returns the specifed SBB icon.
* Image(sbbIcon: ``SBBIcon``): Returns the specifed SBB icon.
* Slider.sbbStyle(imageLeft: Image, imageRight: Image): Applies SBB styling to a Slider.

## Topics
Expand Down
41 changes: 41 additions & 0 deletions SBBDesignSystemMobileSwiftUI/Helper/SBBIconsHelper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Copyright © 2023 SBB. All rights reserved.
//

import Foundation

struct SBBIconsHelper {

static let shared = SBBIconsHelper()

let iconsIndex: SBBIconIndex?

private init() {

if let fileUrl = SBBBundle.getBundle().url(forResource: "SBBIconsIndex", withExtension: "json"), let sbbData = try? Data(contentsOf: fileUrl) {
iconsIndex = try? JSONDecoder().decode(SBBIconIndex.self, from: sbbData)
} else {
iconsIndex = nil
}
}

func hasColor(iconName: String) -> Bool {
if let sbbIconMetadata = iconsIndex?.icons.first(where: {$0.name == iconName}) {
return sbbIconMetadata.color
}
return false
}

}

struct SBBIconMetadata: Decodable {
let name: String
let color: Bool
let scalable: Bool
let tags: [String]
}

struct SBBIconIndex: Decodable {
let version: String
let icons: [SBBIconMetadata]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Loading

0 comments on commit e4f34d1

Please sign in to comment.