├── .editorconfig ├── .gitignore ├── .swift-version ├── CHANGELOG.md ├── CODEOWNERS ├── CONTRIBUTING.md ├── Demo-Swift ├── CustomFont.bundle │ ├── Lato-Bold.ttf │ ├── Lato-Light.ttf │ ├── Lato-Regular.ttf │ ├── Lato-Semibold.ttf │ ├── Lato-Thin.ttf │ └── OpenFontLicense.txt ├── SalesforceDesignSystem.bundle │ ├── License-for-SalesforceDesignSystemIcons.txt │ ├── License-for-SalesforceSans-font.txt │ ├── SalesforceDesignSystemIcons.eot │ ├── SalesforceDesignSystemIcons.ttf │ ├── SalesforceDesignSystemIcons.woff │ ├── SalesforceSans-Bold.ttf │ ├── SalesforceSans-BoldItalic.ttf │ ├── SalesforceSans-Italic.ttf │ ├── SalesforceSans-Light.ttf │ ├── SalesforceSans-LightItalic.ttf │ ├── SalesforceSans-Regular.ttf │ ├── SalesforceSans-Thin.ttf │ └── SalesforceSans-ThinItalic.ttf ├── slds-bridging-header.h ├── slds-sample-app.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── slds-sample-app │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── iTunesArtwork.png │ │ └── iTunesArtwork@2x.png │ ├── Contents.json │ ├── LaunchImage.launchimage │ │ ├── 792x-1.png │ │ ├── 792x.png │ │ ├── 79r4-1.png │ │ ├── 79r4.png │ │ ├── Contents.json │ │ ├── older.png │ │ ├── r4.7.png │ │ └── r5.5.png │ ├── checkered.imageset │ │ ├── Contents.json │ │ ├── checkered-1.png │ │ ├── checkered-2.png │ │ └── checkered.png │ ├── exampleApp.imageset │ │ ├── Contents.json │ │ ├── exampleApp.png │ │ ├── exampleApp@2x.png │ │ └── exampleApp@3x.png │ └── tokens.imageset │ │ ├── Contents.json │ │ ├── tokens.png │ │ ├── tokens@2x.png │ │ └── tokens@3x.png │ ├── Info.plist │ ├── MainListViewController.swift │ ├── SearchController.swift │ ├── demo │ ├── controllers │ │ ├── AccountDetailListViewController.swift │ │ ├── AccountDetailViewController.swift │ │ ├── AccountMasterListViewController.swift │ │ ├── AccountMasterViewController.swift │ │ └── DemoViewController.swift │ ├── controls │ │ ├── AccountTableViewRowAction.swift │ │ ├── ActionBar.swift │ │ └── ActionBarButton.swift │ └── views │ │ ├── AccountDetailCell.swift │ │ ├── AccountDetailHeaderView.swift │ │ ├── AccountHeaderView.swift │ │ ├── AccountMasterCell.swift │ │ └── AccountMasterHeaderView.swift │ └── library │ ├── controllers │ ├── ColorListViewController.swift │ ├── ColorViewController.swift │ ├── FontListViewController.swift │ ├── FontViewController.swift │ ├── IconListViewController.swift │ ├── IconViewController.swift │ └── LibraryListViewController.swift │ ├── controls │ ├── ItemBar.swift │ └── TabBar.swift │ ├── extensions │ ├── String+TrimPrefix.swift │ └── UIView+Constraints.swift │ ├── model │ ├── ApplicationModel.swift │ ├── ColorObject.swift │ └── IconObject.swift │ └── views │ ├── AboutCell.swift │ ├── CodeView.swift │ ├── ColorCell.swift │ ├── DemoCell.swift │ ├── LibraryCell.swift │ ├── SectionHeaderView.swift │ └── SwatchView.swift ├── DesignSystem.podspec ├── LICENSE.txt ├── README.md ├── SalesforceDesignSystem.bundle ├── License-for-SalesforceDesignSystemIcons.txt ├── License-for-SalesforceSans-font.txt ├── SalesforceDesignSystemIcons.ttf ├── SalesforceSans-Bold.ttf ├── SalesforceSans-BoldItalic.ttf ├── SalesforceSans-Italic.ttf ├── SalesforceSans-Light.ttf ├── SalesforceSans-LightItalic.ttf ├── SalesforceSans-Regular.ttf ├── SalesforceSans-Thin.ttf └── SalesforceSans-ThinItalic.ttf ├── SalesforceDesignSystem.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── xcshareddata │ └── xcschemes │ ├── SalesforceDesignSystem.xcscheme │ └── SalesforceDesignSystemNames.xcscheme ├── SalesforceDesignSystem ├── DesignSystemTests │ ├── Info.plist │ └── SLDSTests.m ├── Generated │ ├── Extensions │ │ ├── NSString+SLDSName.h │ │ ├── NSString+SLDSName.m │ │ ├── UIColor+SLDSColor.h │ │ ├── UIColor+SLDSColor.m │ │ ├── UIFont+SLDSFont.h │ │ ├── UIFont+SLDSFont.m │ │ ├── UIImage+SLDSIcon.h │ │ └── UIImage+SLDSIcon.m │ ├── SLDSColor.h │ ├── SLDSFont.h │ ├── SLDSFont.m │ ├── SLDSIcon.h │ ├── SLDSName.h │ └── SLDSSize.h ├── SalesforceDesignSystem.h └── SalesforceDesignSystemNames.h ├── gulpfile.js ├── manual_install_info ├── README.md ├── bundleResource.png ├── linkedLibrary.png ├── linkerFlag.png └── targetDependency.png ├── package-lock.json ├── package.json ├── templates ├── Font │ ├── SLDSFont.h.njk │ ├── SLDSFont.m.njk │ ├── UIFont.h.njk │ └── UIFont.m.njk ├── Icon │ ├── SLDSIcon.h.njk │ ├── UIImage.h.njk │ └── UIImage.m.njk ├── Name │ ├── NSString.h.njk │ ├── NSString.m.njk │ └── SLDSName.h.njk ├── color │ ├── SLDSColor.h.njk │ ├── UIColor.h.njk │ └── UIColor.m.njk └── size │ └── SLDSSize.h.njk └── test └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [Makefile] 15 | indent_style = tab 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | *.xcscmblueprint 20 | 21 | # CocoaPods 22 | # 23 | # We recommend against adding the Pods directory to your .gitignore. However 24 | # you should judge for yourself, the pros and cons are mentioned at: 25 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 26 | # 27 | Pods/ 28 | 29 | .DS_Store 30 | 31 | node_modules/ 32 | npm-debug.log 33 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 2.3 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](http://keepachangelog.com/) 6 | and this project adheres to [Semantic Versioning](http://semver.org/). 7 | 8 | 9 | 10 | ## 3.1.0 - 10/2/2017 11 | Library updated with Winter '18 tokens 12 | 13 | ## 3.0.7 - 6/5/2017 14 | Added color overrides. 15 | Reordered the sample app library listing. 16 | Updated the usage docs. 17 | 18 | ## 3.0.6 - 3/8/2017 19 | Updated the usage docs. 20 | 21 | ## 3.0.5 - 3/2/2017 22 | Fixed an issue with locating the framework bundle. 23 | 24 | ## 3.0.4 - 3/1/2017 25 | Updated links in README.md to absolute paths (for CocoaPods site documentation). 26 | 27 | ## 3.0.3 - 2/27/2017 28 | Instructions updated to reflect detailed pod installation. 29 | 30 | ## 3.0.0 - 2/15/2017 31 | With the introduction of the 3.0.0 release of the SLDS iOS library, there were a fair amount of API changes. Where possible functions were marked as deprecated but not everywhere. The new library aimed to add simplicity wherever possible. 32 | 33 | [Readme.md](https://github.com/salesforce-ux/design-system-ios/blob/master/README.md) 34 | 35 | ### Added 36 | - Integration of the Spring ’17 SLDS Design tokens 37 | - Additional SalesforceSans font family support 38 | - Font substitution mechanism for overriding default fonts 39 | - A swift based sample and library reference app 40 | - ObjectiveC unit tests 41 | - Library generation script unit tests 42 | 43 | ### Changed 44 | - Comprehensive rewrite of the library generation gulp scripts 45 | - File templates have been ported to nunjunks 46 | - Consolidated all icons into a single icon font 47 | - Consolidated SLDS Token values to .h files only 48 | 49 | ## Pre 3.0.0 50 | 51 | Previous release notes are available on GitHub: 52 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | #ECCN:EAR99,Open Source -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Code 2 | 3 | External contributors are required to sign a Contributor’s License Agreement. 4 | You will be prompted to sign it when you open a pull request. 5 | 6 | 1. Create a new issue before starting your project so that we can keep 7 | track of what you are trying to add/fix. That way, we can also offer 8 | suggestions or let you know if there is already an effort in progress. 9 | 2. Fork off this repository. 10 | 3. Create a topic branch for the issue that you are trying to add. 11 | When possible, you should branch off the default branch. 12 | 4. Edit the code in your fork. 13 | 5. Send us a well documented pull request when you are done. 14 | 15 | The **GitHub pull requests** should meet the following criteria: 16 | 17 | - Descriptive title 18 | - Brief summary 19 | - @mention several relevant people to review the code 20 | - Add helpful GitHub comments on lines that you have questions / concerns about 21 | 22 | We’ll review your code, suggest any needed changes, and merge it in. Thank you. 23 | -------------------------------------------------------------------------------- /Demo-Swift/CustomFont.bundle/Lato-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/CustomFont.bundle/Lato-Bold.ttf -------------------------------------------------------------------------------- /Demo-Swift/CustomFont.bundle/Lato-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/CustomFont.bundle/Lato-Light.ttf -------------------------------------------------------------------------------- /Demo-Swift/CustomFont.bundle/Lato-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/CustomFont.bundle/Lato-Regular.ttf -------------------------------------------------------------------------------- /Demo-Swift/CustomFont.bundle/Lato-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/CustomFont.bundle/Lato-Semibold.ttf -------------------------------------------------------------------------------- /Demo-Swift/CustomFont.bundle/Lato-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/CustomFont.bundle/Lato-Thin.ttf -------------------------------------------------------------------------------- /Demo-Swift/CustomFont.bundle/OpenFontLicense.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2015, Łukasz Dziedzic (dziedzic@typoland.com), 2 | with Reserved Font Name Lato. 3 | 4 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 5 | This license is copied below, and is also available with a FAQ at: 6 | http://scripts.sil.org/OFL 7 | 8 | 9 | ----------------------------------------------------------- 10 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 11 | ----------------------------------------------------------- 12 | 13 | PREAMBLE 14 | The goals of the Open Font License (OFL) are to stimulate worldwide 15 | development of collaborative font projects, to support the font creation 16 | efforts of academic and linguistic communities, and to provide a free and 17 | open framework in which fonts may be shared and improved in partnership 18 | with others. 19 | 20 | The OFL allows the licensed fonts to be used, studied, modified and 21 | redistributed freely as long as they are not sold by themselves. The 22 | fonts, including any derivative works, can be bundled, embedded, 23 | redistributed and/or sold with any software provided that any reserved 24 | names are not used by derivative works. The fonts and derivatives, 25 | however, cannot be released under any other type of license. The 26 | requirement for fonts to remain under this license does not apply 27 | to any document created using the fonts or their derivatives. 28 | 29 | DEFINITIONS 30 | "Font Software" refers to the set of files released by the Copyright 31 | Holder(s) under this license and clearly marked as such. This may 32 | include source files, build scripts and documentation. 33 | 34 | "Reserved Font Name" refers to any names specified as such after the 35 | copyright statement(s). 36 | 37 | "Original Version" refers to the collection of Font Software components as 38 | distributed by the Copyright Holder(s). 39 | 40 | "Modified Version" refers to any derivative made by adding to, deleting, 41 | or substituting -- in part or in whole -- any of the components of the 42 | Original Version, by changing formats or by porting the Font Software to a 43 | new environment. 44 | 45 | "Author" refers to any designer, engineer, programmer, technical 46 | writer or other person who contributed to the Font Software. 47 | 48 | PERMISSION & CONDITIONS 49 | Permission is hereby granted, free of charge, to any person obtaining 50 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 51 | redistribute, and sell modified and unmodified copies of the Font 52 | Software, subject to the following conditions: 53 | 54 | 1) Neither the Font Software nor any of its individual components, 55 | in Original or Modified Versions, may be sold by itself. 56 | 57 | 2) Original or Modified Versions of the Font Software may be bundled, 58 | redistributed and/or sold with any software, provided that each copy 59 | contains the above copyright notice and this license. These can be 60 | included either as stand-alone text files, human-readable headers or 61 | in the appropriate machine-readable metadata fields within text or 62 | binary files as long as those fields can be easily viewed by the user. 63 | 64 | 3) No Modified Version of the Font Software may use the Reserved Font 65 | Name(s) unless explicit written permission is granted by the corresponding 66 | Copyright Holder. This restriction only applies to the primary font name as 67 | presented to the users. 68 | 69 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 70 | Software shall not be used to promote, endorse or advertise any 71 | Modified Version, except to acknowledge the contribution(s) of the 72 | Copyright Holder(s) and the Author(s) or with their explicit written 73 | permission. 74 | 75 | 5) The Font Software, modified or unmodified, in part or in whole, 76 | must be distributed entirely under this license, and must not be 77 | distributed under any other license. The requirement for fonts to 78 | remain under this license does not apply to any document created 79 | using the Font Software. 80 | 81 | TERMINATION 82 | This license becomes null and void if any of the above conditions are 83 | not met. 84 | 85 | DISCLAIMER 86 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 87 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 88 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 89 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 90 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 91 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 92 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 93 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 94 | OTHER DEALINGS IN THE FONT SOFTWARE. 95 | -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceDesignSystemIcons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceDesignSystemIcons.eot -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceDesignSystemIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceDesignSystemIcons.ttf -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceDesignSystemIcons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceDesignSystemIcons.woff -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Bold.ttf -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-BoldItalic.ttf -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Italic.ttf -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Light.ttf -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-LightItalic.ttf -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Regular.ttf -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-Thin.ttf -------------------------------------------------------------------------------- /Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/SalesforceDesignSystem.bundle/SalesforceSans-ThinItalic.ttf -------------------------------------------------------------------------------- /Demo-Swift/slds-bridging-header.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #ifndef slds_bridging_header_h 5 | #define slds_bridging_header_h 6 | 7 | #import 8 | #import 9 | 10 | #endif /* slds_bridging_header_h */ 11 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | @UIApplicationMain 7 | 8 | class AppDelegate: UIResponder, UIApplicationDelegate { 9 | 10 | var window: UIWindow? 11 | 12 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 13 | 14 | UIApplication.shared.statusBarStyle = .lightContent 15 | 16 | window = UIWindow(frame: UIScreen.main.bounds) 17 | if let window = window { 18 | window.backgroundColor = UIColor.white 19 | window.rootViewController = UINavigationController(rootViewController: MainListViewController()) 20 | window.makeKeyAndVisible() 21 | } 22 | return true 23 | } 24 | 25 | func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { 26 | return UIInterfaceOrientationMask.portrait 27 | } 28 | 29 | func applicationWillResignActive(_ application: UIApplication) { 30 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 31 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 32 | } 33 | 34 | func applicationDidEnterBackground(_ application: UIApplication) { 35 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 37 | } 38 | 39 | func applicationWillEnterForeground(_ application: UIApplication) { 40 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 41 | } 42 | 43 | func applicationDidBecomeActive(_ application: UIApplication) { 44 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 45 | } 46 | 47 | func applicationWillTerminate(_ application: UIApplication) { 48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "iTunesArtwork.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "60x60", 41 | "idiom" : "iphone", 42 | "filename" : "iTunesArtwork@2x.png", 43 | "scale" : "3x" 44 | } 45 | ], 46 | "info" : { 47 | "version" : 1, 48 | "author" : "xcode" 49 | } 50 | } -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/AppIcon.appiconset/iTunesArtwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/AppIcon.appiconset/iTunesArtwork.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/AppIcon.appiconset/iTunesArtwork@2x.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/792x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/792x-1.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/792x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/792x.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/79r4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/79r4-1.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/79r4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/79r4.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "filename" : "older.png", 7 | "extent" : "full-screen", 8 | "scale" : "1x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "filename" : "792x.png", 14 | "extent" : "full-screen", 15 | "scale" : "2x" 16 | }, 17 | { 18 | "orientation" : "portrait", 19 | "idiom" : "iphone", 20 | "filename" : "79r4.png", 21 | "extent" : "full-screen", 22 | "subtype" : "retina4", 23 | "scale" : "2x" 24 | }, 25 | { 26 | "extent" : "full-screen", 27 | "idiom" : "iphone", 28 | "subtype" : "736h", 29 | "filename" : "r5.5.png", 30 | "minimum-system-version" : "8.0", 31 | "orientation" : "portrait", 32 | "scale" : "3x" 33 | }, 34 | { 35 | "extent" : "full-screen", 36 | "idiom" : "iphone", 37 | "subtype" : "667h", 38 | "filename" : "r4.7.png", 39 | "minimum-system-version" : "8.0", 40 | "orientation" : "portrait", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "orientation" : "portrait", 45 | "idiom" : "iphone", 46 | "filename" : "792x-1.png", 47 | "extent" : "full-screen", 48 | "minimum-system-version" : "7.0", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "extent" : "full-screen", 53 | "idiom" : "iphone", 54 | "subtype" : "retina4", 55 | "filename" : "79r4-1.png", 56 | "minimum-system-version" : "7.0", 57 | "orientation" : "portrait", 58 | "scale" : "2x" 59 | } 60 | ], 61 | "info" : { 62 | "version" : 1, 63 | "author" : "xcode" 64 | } 65 | } -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/older.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/older.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/r4.7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/r4.7.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/r5.5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/LaunchImage.launchimage/r5.5.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/checkered.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "checkered.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "checkered-1.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "checkered-2.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/checkered.imageset/checkered-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/checkered.imageset/checkered-1.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/checkered.imageset/checkered-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/checkered.imageset/checkered-2.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/checkered.imageset/checkered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/checkered.imageset/checkered.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/exampleApp.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "exampleApp.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "exampleApp@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "exampleApp@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/exampleApp.imageset/exampleApp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/exampleApp.imageset/exampleApp.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/exampleApp.imageset/exampleApp@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/exampleApp.imageset/exampleApp@2x.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/exampleApp.imageset/exampleApp@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/exampleApp.imageset/exampleApp@3x.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/tokens.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "tokens.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "tokens@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "tokens@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/tokens.imageset/tokens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/tokens.imageset/tokens.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/tokens.imageset/tokens@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/tokens.imageset/tokens@2x.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Assets.xcassets/tokens.imageset/tokens@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/Demo-Swift/slds-sample-app/Assets.xcassets/tokens.imageset/tokens@3x.png -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIAppFonts 6 | 7 | SalesforceDesignSystemIcons.ttf 8 | 9 | CFBundleDevelopmentRegion 10 | en 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UIViewControllerBasedStatusBarAppearance 36 | 37 | UIStatusBarStyle 38 | light 39 | 40 | 41 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/MainListViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class MainListViewController: UITableViewController { 7 | 8 | var footerHeight : CGFloat = 200.0 9 | 10 | var tableData : [(name:String, cell:UITableViewCell.Type, controller:UIViewController.Type)] { 11 | return [("DemoCell", DemoCell.self, DemoViewController.self), 12 | ("LibraryCell", LibraryCell.self, LibraryListViewController.self), 13 | ("AboutCell", AboutCell.self, UIViewController.self)] 14 | } 15 | 16 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 17 | 18 | override var preferredStatusBarStyle: UIStatusBarStyle { 19 | return .lightContent 20 | } 21 | 22 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 23 | 24 | override func viewDidLoad() { 25 | for item in self.tableData { 26 | self.tableView.register(item.cell, forCellReuseIdentifier: item.name) 27 | } 28 | 29 | self.view.backgroundColor = UIColor.sldsBackgroundColor(.colorBackgroundRowSelected) 30 | 31 | self.tableView.separatorStyle = .none 32 | 33 | self.navigationController?.navigationBar.isTranslucent = false 34 | 35 | self.navigationController?.navigationBar.tintColor = UIColor.sldsTextColor(.colorTextButtonBrand) 36 | self.navigationController?.navigationBar.barTintColor = UIColor.sldsFill(.brandActive) 37 | 38 | self.navigationController?.navigationBar.backIndicatorImage = UIImage.sldsUtilityIcon(.chevronleft, withSize:SLDSSquareIconUtilityMedium) 39 | 40 | self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage.sldsUtilityIcon(.chevronleft, 41 | withSize: SLDSSquareIconUtilityMedium).withAlignmentRectInsets(UIEdgeInsetsMake(0, 0, -1, 0)) 42 | 43 | self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white, 44 | NSFontAttributeName: UIFont.sldsFont(.regular, with: .medium)] 45 | 46 | self.title = "Lightning Design System" 47 | self.tableView.alwaysBounceVertical = false 48 | } 49 | 50 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 51 | 52 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 53 | let rowHeight = (self.view.frame.height - tableView.contentInset.top) / CGFloat(tableData.count) 54 | if indexPath.row < tableData.count - 1 { 55 | return rowHeight + 70 56 | } 57 | return rowHeight - 140 58 | } 59 | 60 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 61 | 62 | override func numberOfSections(in tableView: UITableView) -> Int { 63 | return 1 64 | } 65 | 66 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 67 | 68 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 69 | return tableData.count 70 | } 71 | 72 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 73 | 74 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 75 | let cell = tableView.dequeueReusableCell(withIdentifier: tableData[indexPath.row].name) 76 | return cell! 77 | } 78 | 79 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 80 | 81 | override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { 82 | if indexPath.row == tableData.count - 1 { 83 | return nil 84 | } 85 | return indexPath 86 | } 87 | 88 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 89 | 90 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 91 | let controllerClass = tableData[indexPath.row].controller 92 | let controller = controllerClass.init() 93 | self.navigationController?.show(controller, sender: self) 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/SearchController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 7 | 8 | class SearchController: UIViewController, UISearchBarDelegate { 9 | 10 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 11 | 12 | var searchHeader = UISearchBar() 13 | var filterString : String = "" 14 | 15 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | self.view.backgroundColor = UIColor.white 20 | styleSearch() 21 | } 22 | 23 | // MARK: Styling methods 24 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 25 | 26 | func styleSearch() { 27 | searchHeader.delegate = self 28 | searchHeader.placeholder = "Search" 29 | searchHeader.keyboardType = .alphabet 30 | searchHeader.returnKeyType = .done 31 | searchHeader.autocapitalizationType = .none 32 | searchHeader.autocorrectionType = .no 33 | searchHeader.tintColor = UIColor.sldsBackgroundColor(.colorBrand) 34 | searchHeader.barTintColor = UIColor.sldsBackgroundColor(.colorBackground) 35 | searchHeader.backgroundColor = UIColor.white 36 | self.view.addSubview(searchHeader) 37 | self.view.constrainChild(searchHeader, 38 | xAlignment: .center, 39 | yAlignment: .top, 40 | width: self.view.frame.width) 41 | } 42 | 43 | // MARK: UISearchBarDelegate 44 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 45 | 46 | func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { 47 | self.searchHeader.setShowsCancelButton(true, animated: true) 48 | } 49 | 50 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 51 | 52 | func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { 53 | self.filterString = searchText.lowercased() 54 | } 55 | 56 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 57 | 58 | func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { 59 | searchBar.text = "" 60 | self.filterString = "" 61 | self.view.endEditing(true) 62 | } 63 | 64 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 65 | 66 | func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { 67 | self.view.endEditing(true) 68 | } 69 | 70 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 71 | 72 | func searchBarTextDidEndEditing(_ searchBar: UISearchBar) { 73 | self.searchHeader.setShowsCancelButton(false, animated: true) 74 | } 75 | 76 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 77 | } 78 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/controllers/AccountDetailListViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AccountDetailListViewController: UITableViewController { 7 | 8 | var superNavigationController : UINavigationController! 9 | 10 | var cellValues = Array<(label : String, value : String)>() 11 | 12 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 13 | 14 | var dataProvider : AccountObject? { 15 | didSet { 16 | cellValues.append((label: "Account Owner", 17 | value: (self.dataProvider?.owner)!)) 18 | cellValues.append((label: "Account Name", 19 | value: (self.dataProvider?.name)!)) 20 | cellValues.append((label: "Account Number", 21 | value: (self.dataProvider?.number)!)) 22 | cellValues.append((label: "Type", 23 | value: (self.dataProvider?.type)!.rawValue)) 24 | cellValues.append((label: "Industry", 25 | value: (self.dataProvider?.industry)!)) 26 | cellValues.append((label: "Website", 27 | value: (self.dataProvider?.url)!)) 28 | cellValues.append((label: "Phone", 29 | value: (self.dataProvider?.phone)!)) 30 | } 31 | } 32 | 33 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 34 | 35 | override func viewDidLoad() { 36 | super.viewDidLoad() 37 | 38 | self.tableView.separatorInset = UIEdgeInsets.zero 39 | self.tableView.separatorColor = UIColor.sldsBorderColor(.colorBorderSeparatorAlt) 40 | 41 | self.tableView.register(AccountDetailCell.self, forCellReuseIdentifier: "cell") 42 | } 43 | 44 | // MARK: - Table view data source 45 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 46 | 47 | override func numberOfSections(in tableView: UITableView) -> Int { 48 | return 1 49 | } 50 | 51 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 52 | 53 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 54 | return cellValues.count 55 | } 56 | 57 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 58 | 59 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 60 | return 75 61 | } 62 | 63 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 64 | 65 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> AccountDetailCell { 66 | let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! AccountDetailCell 67 | cell.dataProvider = cellValues[indexPath.item] 68 | 69 | return cell 70 | } 71 | 72 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 73 | } 74 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/controllers/AccountDetailViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AccountDetailViewController: UIViewController { 7 | 8 | var header = AccountDetailHeaderView() 9 | 10 | var tableViewController = AccountDetailListViewController() 11 | 12 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 13 | 14 | var dataProvider : AccountObject? { 15 | didSet { 16 | header.dataProvider = self.dataProvider 17 | tableViewController.dataProvider = self.dataProvider 18 | } 19 | } 20 | 21 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | 26 | self.view.backgroundColor = UIColor.white 27 | 28 | self.view.addSubview(header) 29 | self.view.constrainChild(header, 30 | xAlignment: .left, 31 | yAlignment: .top, 32 | width: self.view.frame.width, 33 | height: 120, 34 | yOffset: 64) 35 | 36 | self.view.addSubview(tableViewController.view) 37 | self.tableViewController.view.constrainBelow(self.header, 38 | xAlignment: .center, 39 | width: self.view.frame.width, 40 | height: self.view.frame.height - 240) 41 | 42 | } 43 | 44 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 45 | } 46 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/controllers/AccountMasterListViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | enum AccountType : String { 7 | case direct = "Customer - Direct" 8 | case channel = "Customer - Channel" 9 | } 10 | 11 | struct AccountObject { 12 | var name : String! 13 | var state : String! 14 | var phone : String! 15 | var type : AccountType! 16 | var owner : String! 17 | var industry : String! 18 | var number : String! 19 | var url : String! 20 | } 21 | 22 | class AccountMasterListViewController: UITableViewController { 23 | 24 | var superNavigationController : UINavigationController! 25 | 26 | let accounts = [ 27 | AccountObject(name: "Burlington Textiles Corp of America", 28 | state: "NC", 29 | phone: "(336) 222-7000", 30 | type: .direct, 31 | owner: "Joe Green", 32 | industry: "Apparel", 33 | number: "CD656092", 34 | url: "www.burlington.com"), 35 | AccountObject(name: "Dickenson Plc", 36 | state: "KS", 37 | phone: "(785) 241-6200", 38 | type: .channel, 39 | owner: "Joe Green", 40 | industry: "Consulting", 41 | number: "CC634267", 42 | url: "dickenson-consulting.com"), 43 | AccountObject(name: "Edge Communications", 44 | state: "TX", 45 | phone: "(512) 757-6000", 46 | type: .direct, 47 | owner: "Joe Green", 48 | industry: "Electronics", 49 | number: "CD451796", 50 | url: "www.edgecomm.com"), 51 | AccountObject(name: "Express Logistics and Transport", 52 | state: "OR", 53 | phone: "(503) 421-7800", 54 | type: .channel, 55 | owner: "Joe Green", 56 | industry: "Transportation", 57 | number: "CC947211", 58 | url: "www.expresslandt.net"), 59 | AccountObject(name: "GenePoint", 60 | state: "CA", 61 | phone: "(650) 867-3450", 62 | type: .channel, 63 | owner: "Joe Green", 64 | industry: "Biotechnology", 65 | number: "CC978213", 66 | url: "www.genepoint.com") 67 | ] 68 | 69 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 70 | 71 | override func viewDidLoad() { 72 | super.viewDidLoad() 73 | 74 | self.tableView.separatorInset = UIEdgeInsets.zero 75 | self.tableView.separatorColor = UIColor.sldsBorderColor(.colorBorderSeparatorAlt) 76 | 77 | self.tableView.register(AccountMasterCell.self, forCellReuseIdentifier: "cell") 78 | } 79 | 80 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 81 | 82 | func popController() { 83 | NotificationCenter.default.post(name: NSNotification.Name("returnToLibrary"), object: self) 84 | } 85 | 86 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 87 | 88 | override func didReceiveMemoryWarning() { 89 | super.didReceiveMemoryWarning() 90 | // Dispose of any resources that can be recreated. 91 | } 92 | 93 | // MARK: - Table view data source 94 | 95 | override func numberOfSections(in tableView: UITableView) -> Int { 96 | // #warning Incomplete implementation, return the number of sections 97 | return 1 98 | } 99 | 100 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 101 | 102 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 103 | // #warning Incomplete implementation, return the number of rows 104 | return accounts.count 105 | } 106 | 107 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 108 | 109 | override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 110 | return 150 111 | } 112 | 113 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 114 | 115 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 116 | let controller = AccountDetailViewController() 117 | controller.dataProvider = accounts[indexPath.item] 118 | 119 | self.superNavigationController.pushViewController(controller, animated: true) 120 | } 121 | 122 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 123 | 124 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> AccountMasterCell { 125 | let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! AccountMasterCell 126 | cell.dataProvider = accounts[indexPath.item] 127 | 128 | return cell 129 | } 130 | 131 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 132 | } 133 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/controllers/AccountMasterViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AccountMasterViewController: UIViewController { 7 | 8 | var header = UIView() 9 | var tableViewController = AccountMasterListViewController() 10 | 11 | let actionBarHeight = CGFloat(56.0) 12 | let headerHeight = CGFloat(72.0) 13 | var tableHeight :CGFloat! 14 | 15 | override func accessibilityPerformEscape() -> Bool { 16 | popController() 17 | return true 18 | } 19 | 20 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 21 | 22 | override func viewDidLoad() { 23 | super.viewDidLoad() 24 | 25 | tableViewController.superNavigationController = self.navigationController 26 | 27 | self.title = "Example App" 28 | 29 | let toolBarOffset = (self.navigationController?.toolbar)!.frame.height + UIApplication.shared.statusBarFrame.height 30 | tableHeight = self.view.frame.height - actionBarHeight - headerHeight - toolBarOffset 31 | 32 | header = AccountMasterHeaderView() 33 | 34 | self.view.addSubview(header) 35 | 36 | self.view.constrainChild(header, 37 | xAlignment: .center, 38 | yAlignment: .top, 39 | width: self.view.frame.width, 40 | height: headerHeight, 41 | yOffset: toolBarOffset) 42 | 43 | self.view.addSubview(tableViewController.view) 44 | tableViewController.view.constrainBelow(header, 45 | xAlignment: .left, 46 | width: self.view.frame.width, 47 | height: tableHeight) 48 | 49 | self.view.backgroundColor = UIColor.white 50 | styleNavigationBar() 51 | } 52 | 53 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 54 | 55 | func styleNavigationBar() { 56 | let newBackButton = UIBarButtonItem(image: UIImage.sldsUtilityIcon(.chevronleft, 57 | withSize: SLDSSquareIconUtilityMedium).withAlignmentRectInsets(UIEdgeInsetsMake(0, 0, -1, 0)), 58 | style: UIBarButtonItemStyle.done, 59 | target: self, 60 | action: #selector(AccountMasterViewController.popController)) 61 | 62 | newBackButton.accessibilityTraits = UIAccessibilityTraitButton 63 | newBackButton.accessibilityLabel = "back button" 64 | navigationItem.leftBarButtonItem = newBackButton 65 | self.navigationController?.navigationBar.barTintColor = UIColor.sldsBackgroundColor(.colorBrand) 66 | self.navigationController?.navigationBar.tintColor = UIColor.white 67 | 68 | self.navigationController?.navigationBar.backIndicatorImage = UIImage.sldsUtilityIcon(.chevronleft, 69 | withSize: SLDSSquareIconUtilityMedium).withAlignmentRectInsets(UIEdgeInsetsMake(0, 0, -1, 0)) 70 | 71 | self.navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage.sldsUtilityIcon(.chevronleft, 72 | withSize: SLDSSquareIconUtilityMedium).withAlignmentRectInsets(UIEdgeInsetsMake(0, 0, -1, 0)) 73 | 74 | self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white, 75 | NSFontAttributeName: UIFont.sldsFont(.regular, with: .medium)] 76 | self.navigationItem.hidesBackButton = false 77 | } 78 | 79 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 80 | 81 | func popController() { 82 | NotificationCenter.default.post(name: NSNotification.Name("returnToLibrary"), object: self) 83 | } 84 | 85 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 86 | 87 | } 88 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/controllers/DemoViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class DemoViewController: UIViewController, ItemBarDelegate, UINavigationControllerDelegate { 7 | 8 | var demoNavigationController : UINavigationController? 9 | 10 | var actionItems = Array() 11 | var actionBar = ActionBar() 12 | var actionBarHeight = CGFloat(56.0) 13 | 14 | var contentViewController = AccountMasterViewController() 15 | 16 | 17 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 18 | 19 | func handleReturnToLibrary() { 20 | _ = self.navigationController?.popViewController(animated: true) 21 | self.navigationController?.isNavigationBarHidden = false 22 | } 23 | 24 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 25 | 26 | override func viewDidLoad() { 27 | super.viewDidLoad() 28 | 29 | NotificationCenter.default.addObserver(self, 30 | selector: #selector(DemoViewController.handleReturnToLibrary), 31 | name: NSNotification.Name("returnToLibrary"), 32 | object: nil) 33 | 34 | demoNavigationController = UINavigationController(rootViewController: contentViewController) 35 | 36 | 37 | if let nav = demoNavigationController?.view { 38 | self.view.addSubview(nav) 39 | } 40 | 41 | actionBar.delegate = self 42 | demoNavigationController?.delegate = self 43 | 44 | self.view.addSubview(actionBar) 45 | self.view.constrainChild(actionBar, 46 | xAlignment: .center, 47 | yAlignment: .bottom, 48 | width: self.view.frame.width, 49 | height: actionBarHeight) 50 | 51 | self.view.backgroundColor = UIColor.white 52 | } 53 | 54 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 55 | 56 | override func viewWillAppear(_ animated: Bool) { 57 | self.navigationController?.setNavigationBarHidden(true, animated: true) 58 | super.viewWillAppear(animated) 59 | } 60 | 61 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 62 | 63 | override func didReceiveMemoryWarning() { 64 | super.didReceiveMemoryWarning() 65 | } 66 | 67 | // MARK - ItemBar delegate 68 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 69 | 70 | func itemBar(_ itemBar: ItemBar, didSelectItemAt index: NSInteger) { 71 | if itemBar == actionBar { 72 | // do something with the selection at index 73 | } 74 | } 75 | 76 | // MARK - UINavigationBar delegate 77 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 78 | 79 | func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { 80 | 81 | if viewController is AccountDetailViewController { 82 | 83 | actionItems = [ 84 | ActionItem(label: "Call", iconId: .call), 85 | ActionItem(label: "Task", iconId: .newTask), 86 | ActionItem(label: "Event", iconId: .newEvent), 87 | ActionItem(label: "Post", iconId: .sharePost), 88 | ActionItem(label: "More", iconId: .more) 89 | ] 90 | 91 | } else { 92 | 93 | actionItems = [ 94 | ActionItem(label: "Filter", iconId: .filter), 95 | ActionItem(label: "Sort", iconId: .sort), 96 | ActionItem(label: "New", iconId: .new) 97 | ] 98 | } 99 | 100 | self.actionBar.hideActionBarButtons() { 101 | self.actionBar.removeItems() 102 | 103 | for item in self.actionItems { 104 | 105 | let button = ActionBarButton() 106 | button.setImage(UIImage.sldsActionIcon(item.iconId, withSize: 28), for: .normal) 107 | button.setTitle(item.label, for: .normal) 108 | self.actionBar.addActionBarButton(button) 109 | } 110 | self.actionBar.showActionBarButtons() 111 | } 112 | } 113 | 114 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 115 | 116 | } 117 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/controls/AccountTableViewRowAction.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, salesforce.com, inc. All rights reserved. 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 5 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 6 | Neither the name of salesforce.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 7 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 8 | */ 9 | 10 | import UIKit 11 | 12 | class AccountTableViewRowAction: UITableViewRowAction { 13 | 14 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 15 | 16 | override func layoutSubviews() { 17 | super.layoutSubviews() 18 | var frame = self.imageView?.frame; 19 | frame = CGRect(x:((self.bounds.size.width - (frame?.size.width)!) / 2), y: 8, width: (frame?.size.width)!, height: (frame?.size.height)!); 20 | self.imageView?.frame = frame!; 21 | 22 | // round icon 23 | imageView?.layer.cornerRadius = (frame?.width)!/2; 24 | imageView?.clipsToBounds = true; 25 | 26 | frame = self.titleLabel?.frame; 27 | frame = CGRect(x: ((self.bounds.size.width - (frame?.size.width)!) / 2), y: self.bounds.size.height - (frame?.size.height)! - 4, width: (frame?.size.width)!, height: (frame?.size.height)!); 28 | self.titleLabel?.frame = frame!; 29 | 30 | // styling 31 | self.titleLabel?.font = UIFont.sldsFont(.regular, with: .xSmall) 32 | self.titleLabel?.textColor = UIColor.sldsColorText(SLDSColorTextType.actionLabel) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/controls/ActionBar.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | struct ActionItem { 7 | var label : String! 8 | var iconId : SLDSActionIconType! 9 | } 10 | 11 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 12 | 13 | class ActionBar: ItemBar { 14 | 15 | var actionItemsHidden: Bool = false 16 | 17 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 18 | 19 | var firstPosition : NSLayoutConstraint? { 20 | guard let first = self.items.first else 21 | { 22 | return nil 23 | } 24 | 25 | for constraint in self.constraints { 26 | if first.isEqual(constraint.firstItem) && 27 | constraint.firstAttribute == .bottom { 28 | return constraint 29 | } 30 | } 31 | return nil 32 | } 33 | 34 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 35 | 36 | override func draw(_ rect: CGRect) { 37 | let aPath = UIBezierPath() 38 | 39 | aPath.move(to: CGPoint(x:0, y:0)) 40 | aPath.addLine(to: CGPoint(x:self.frame.width, y:0)) 41 | aPath.close() 42 | aPath.lineWidth = 1.0 43 | UIColor.sldsBorderColor(.colorBorderSeparatorAlt2).set() 44 | aPath.stroke() 45 | } 46 | 47 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 48 | 49 | func addActionBarButton(_ actionButton : ActionBarButton) { 50 | super.addItem(item: actionButton) 51 | 52 | if self.items.count == 1 { 53 | self.firstPosition?.constant = self.actionItemsHidden ? self.frame.height : 0 54 | } 55 | } 56 | 57 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 58 | 59 | func showActionBarButtons(_ animated : Bool=true, completion: ( (Void) -> (Void) )?=nil ) { 60 | self.actionItemsHidden = false 61 | animateActionBarButtons(animated, completion: completion) } 62 | 63 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 64 | 65 | func hideActionBarButtons(_ animated : Bool=true, completion: ( (Void) -> (Void) )?=nil ) { 66 | self.actionItemsHidden = true 67 | animateActionBarButtons(animated, completion: completion) 68 | } 69 | 70 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 71 | 72 | private func animateActionBarButtons(_ animated : Bool=true, completion: ( (Void) -> (Void) )?=nil ) { 73 | let ease = self.actionItemsHidden ? UIViewAnimationOptions.curveEaseIn : UIViewAnimationOptions.curveEaseOut 74 | 75 | self.firstPosition?.constant = self.actionItemsHidden ? 56 : 0 76 | 77 | guard animated else { 78 | self.layoutIfNeeded() 79 | if completion != nil { 80 | completion!() 81 | } 82 | return 83 | } 84 | 85 | UIView.animate(withDuration: 0.3, 86 | delay: 0, 87 | options: ease, animations: { 88 | self.layoutIfNeeded() 89 | }, completion: { (Bool) in 90 | if completion != nil { 91 | completion!() 92 | } 93 | }) 94 | } 95 | 96 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 97 | 98 | } 99 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/controls/ActionBarButton.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class ActionBarButton: UIButton { 7 | 8 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 9 | 10 | override func layoutSubviews() { 11 | super.layoutSubviews() 12 | var frame = self.imageView?.frame; 13 | frame = CGRect(x:((self.bounds.size.width - (frame?.size.width)!) / 2), y: 8, width: (frame?.size.width)!, height: (frame?.size.height)!); 14 | self.imageView?.frame = frame!; 15 | 16 | frame = self.titleLabel?.frame; 17 | frame = CGRect(x: ((self.bounds.size.width - (frame?.size.width)!) / 2), y: self.bounds.size.height - (frame?.size.height)! - 4, width: (frame?.size.width)!, height: (frame?.size.height)!); 18 | self.titleLabel?.frame = frame!; 19 | 20 | // styling 21 | self.titleLabel?.font = UIFont.sldsFont(.regular, with: .xSmall) 22 | self.titleLabel?.textColor = UIColor.sldsTextColor(.colorTextActionLabel) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/views/AccountDetailCell.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AccountDetailCell: UITableViewCell { 7 | 8 | var label = UILabel() 9 | var value = UILabel() 10 | 11 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 12 | 13 | var dataProvider : (label : String, value : String)? { 14 | 15 | didSet { 16 | self.label.text = dataProvider?.label 17 | self.value.text = dataProvider?.value 18 | } 19 | } 20 | 21 | 22 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 23 | 24 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 25 | super.init(style: style, reuseIdentifier: reuseIdentifier) 26 | self.makeLayout() 27 | } 28 | 29 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 30 | 31 | required init?(coder aDecoder: NSCoder) { 32 | super.init(coder: aDecoder) 33 | } 34 | 35 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 36 | 37 | func makeLayout() { 38 | 39 | let font = UIFont.sldsFont(.regular, with: .medium) 40 | let labelColor = UIColor.sldsTextColor(.colorTextActionLabel) 41 | let valueColor = UIColor.sldsTextColor(.colorTextDefault) 42 | 43 | label.font = font 44 | label.textColor = labelColor 45 | self.addSubview(label) 46 | 47 | value.font = font 48 | value.textColor = valueColor 49 | self.addSubview(value) 50 | 51 | self.constrainChild(label, 52 | xAlignment: .left, 53 | yAlignment: .top, 54 | xOffset: SLDSSpacingMedium, 55 | yOffset: SLDSSpacingMedium) 56 | 57 | self.value.constrainBelow(label, 58 | xAlignment: .left, 59 | yOffset: 1) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/views/AccountDetailHeaderView.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AccountDetailHeaderView: AccountHeaderView, ItemBarDelegate { 7 | 8 | var accountType = UILabel() 9 | var phoneNumber = UILabel() 10 | var url = UILabel() 11 | 12 | var tabBar = TabBar() 13 | 14 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 15 | 16 | var dataProvider : AccountObject? { 17 | didSet { 18 | self.headerTitle.text = dataProvider?.name 19 | self.accountType.text = (dataProvider?.type.rawValue)! + " ・ " 20 | self.phoneNumber.text = (dataProvider?.phone)! + " ・" 21 | self.url.text = dataProvider?.url 22 | } 23 | } 24 | 25 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 26 | 27 | override func makeLayout() { 28 | super.makeLayout() 29 | 30 | tabBar.delegate = self 31 | 32 | self.headerTitle.font = UIFont.sldsFont(.regular, with: .medium) 33 | 34 | accountType.font = UIFont.sldsFont(.regular, with: .small) 35 | accountType.textColor = UIColor.sldsTextColor(.colorTextDefault) 36 | 37 | phoneNumber.font = UIFont.sldsFont(.regular, with: .small) 38 | phoneNumber.textColor = UIColor.sldsTextColor(.colorTextLink) 39 | 40 | url.font = UIFont.sldsFont(.regular, with: .small) 41 | url.textColor = UIColor.sldsTextColor(.colorTextLink) 42 | 43 | self.addSubview(accountType) 44 | accountType.constrainBelow(self.headerTitle, 45 | xAlignment: .left, 46 | yOffset: 2) 47 | 48 | self.addSubview(phoneNumber) 49 | phoneNumber.constrainRightOf(accountType, 50 | yAlignment: .center, 51 | xOffset: 2) 52 | 53 | self.addSubview(url) 54 | url.constrainBelow(self.accountType, 55 | xAlignment: .left, 56 | yOffset: 0) 57 | 58 | tabBar.addTab(withLabelString: "feed") 59 | tabBar.addTab(withLabelString: "details") 60 | tabBar.addTab(withLabelString: "related") 61 | 62 | tabBar.backgroundColor = UIColor.sldsBackgroundColor(.colorBackground) 63 | 64 | self.addSubview(tabBar) 65 | } 66 | 67 | override func layoutSubviews() { 68 | self.constrainChild(tabBar, 69 | xAlignment: .center, 70 | yAlignment: .bottom, 71 | width: self.frame.width, 72 | height: 30) 73 | 74 | tabBar.moveUnderscore(1) 75 | } 76 | 77 | // MARK: - TabBar delegate 78 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 79 | 80 | func itemBar(_ itemBar: ItemBar, didSelectItemAt index: NSInteger) { 81 | 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/views/AccountHeaderView.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AccountHeaderView: UIView { 7 | 8 | var headerIcon = UIImageView() 9 | var headerTitle = UILabel() 10 | 11 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 12 | 13 | override func draw(_ rect: CGRect) { 14 | let aPath = UIBezierPath() 15 | 16 | aPath.move(to: CGPoint(x:0, y:self.frame.height)) 17 | aPath.addLine(to: CGPoint(x:self.frame.width, y:self.frame.height)) 18 | aPath.close() 19 | aPath.lineWidth = 1.0 20 | UIColor.sldsBorderColor(.colorBorderSeparatorAlt2).set() 21 | aPath.stroke() 22 | } 23 | 24 | 25 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 26 | 27 | override init (frame : CGRect) { 28 | super.init(frame : frame) 29 | self.makeLayout() 30 | } 31 | 32 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 33 | 34 | convenience init () { 35 | self.init(frame:CGRect.zero) 36 | } 37 | 38 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 39 | 40 | required init(coder aDecoder: NSCoder) { 41 | fatalError("This class does not support NSCoding") 42 | } 43 | 44 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 45 | 46 | func makeLayout() { 47 | self.backgroundColor = UIColor.sldsBackgroundColor(.colorBackground) 48 | 49 | 50 | headerIcon = UIImageView(image: UIImage.sldsStandardIcon(.account, 51 | withSize: SLDSSquareIconMedium)) 52 | self.addSubview(headerIcon) 53 | 54 | self.constrainChild(headerIcon, 55 | xAlignment: .left, 56 | yAlignment: .top, 57 | xOffset: 10, 58 | yOffset: 10) 59 | 60 | headerTitle = UILabel() 61 | headerTitle.font = UIFont.sldsFont(.regular, with: .large) 62 | 63 | headerTitle.textColor = UIColor.sldsTextColor(.colorTextDefault) 64 | 65 | self.addSubview(headerTitle) 66 | headerTitle.constrainRightOf(headerIcon, 67 | yAlignment: .top, 68 | xOffset: 15) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/views/AccountMasterCell.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AccountMasterCell: UITableViewCell { 7 | 8 | var accountName = UILabel() 9 | var stateLabel = UILabel() 10 | var phoneLabel = UILabel() 11 | var typeLabel = UILabel() 12 | var ownerLabel = UILabel() 13 | 14 | var stateValue = UILabel() 15 | var phoneValue = UILabel() 16 | var typeValue = UILabel() 17 | var ownerValue = UILabel() 18 | 19 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 20 | 21 | var dataProvider : AccountObject? { 22 | 23 | didSet { 24 | self.accountName.text = dataProvider?.name 25 | self.stateValue.text = dataProvider?.state 26 | self.stateValue.accessibilityLabel = "Billing State " + self.stateValue.text! 27 | 28 | self.phoneValue.text = dataProvider?.phone 29 | self.phoneValue.accessibilityLabel = "Phone " + self.phoneValue.text! 30 | 31 | self.typeValue.text = dataProvider?.type.rawValue 32 | self.typeValue.accessibilityLabel = "Type " + self.typeValue.text! 33 | 34 | self.ownerValue.text = dataProvider?.owner 35 | self.ownerValue.accessibilityLabel = "Owner " + self.ownerValue.text! 36 | } 37 | } 38 | 39 | 40 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 41 | 42 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 43 | super.init(style: style, reuseIdentifier: reuseIdentifier) 44 | self.makeLayout() 45 | } 46 | 47 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 48 | 49 | required init?(coder aDecoder: NSCoder) { 50 | super.init(coder: aDecoder) 51 | } 52 | 53 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 54 | 55 | override func layoutSubviews() { 56 | super.layoutSubviews() 57 | } 58 | 59 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 60 | 61 | override func setSelected(_ selected: Bool, animated: Bool) { 62 | super.setSelected(selected, animated: animated) 63 | } 64 | 65 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 66 | 67 | override func setHighlighted(_ highlighted: Bool, animated: Bool) { 68 | super.setHighlighted(highlighted, animated: animated) 69 | } 70 | 71 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 72 | 73 | func makeLayout() { 74 | 75 | let font = UIFont.sldsFont(.regular, with: .medium) 76 | let labelColor = UIColor.sldsTextColor(.colorTextActionLabel) 77 | let valueColor = UIColor.sldsTextColor(.colorTextDefault) 78 | 79 | accountName.font = font 80 | accountName.textColor = valueColor 81 | self.addSubview(accountName) 82 | 83 | stateLabel.font = font 84 | stateLabel.textColor = labelColor 85 | stateLabel.text = "Billing State:" 86 | self.addSubview(stateLabel) 87 | 88 | phoneLabel.font = font 89 | phoneLabel.textColor = labelColor 90 | phoneLabel.text = "Phone:" 91 | self.addSubview(phoneLabel) 92 | 93 | typeLabel.font = font 94 | typeLabel.textColor = labelColor 95 | typeLabel.text = "Type:" 96 | self.addSubview(typeLabel) 97 | 98 | ownerLabel.text = "Owner:" 99 | ownerLabel.font = font 100 | ownerLabel.textColor = labelColor 101 | self.addSubview(ownerLabel) 102 | 103 | stateValue.font = font 104 | stateValue.textColor = valueColor 105 | self.addSubview(stateValue) 106 | 107 | phoneValue.font = font 108 | phoneValue.textColor = valueColor 109 | self.addSubview(phoneValue) 110 | 111 | typeValue.font = font 112 | typeValue.textColor = valueColor 113 | self.addSubview(typeValue) 114 | 115 | ownerValue.font = font 116 | ownerValue.textColor = valueColor 117 | self.addSubview(ownerValue) 118 | 119 | self.accessibilityElements = [accountName, stateValue, phoneValue, typeValue, ownerValue] 120 | 121 | self.constrainChild(accountName, 122 | xAlignment: .left, 123 | yAlignment: .top, 124 | xOffset: SLDSSpacingMedium, 125 | yOffset: SLDSSpacingMedium) 126 | 127 | self.stateLabel.constrainBelow(accountName, 128 | xAlignment: .left, 129 | yOffset: 3) 130 | 131 | self.phoneLabel.constrainBelow(stateLabel, 132 | xAlignment: .left, 133 | yOffset: 1) 134 | 135 | self.typeLabel.constrainBelow(phoneLabel, 136 | xAlignment: .left, 137 | yOffset: 1) 138 | 139 | self.ownerLabel.constrainBelow(typeLabel, 140 | xAlignment: .left, 141 | yOffset: 1) 142 | 143 | // values 144 | 145 | self.stateValue.constrainRightOf(stateLabel, 146 | yAlignment: .center, 147 | xOffset: 30) 148 | 149 | self.phoneValue.constrainBelow(stateValue, 150 | xAlignment: .left, 151 | yOffset: 1) 152 | 153 | self.typeValue.constrainBelow(phoneValue, 154 | xAlignment: .left, 155 | yOffset: 1) 156 | 157 | self.ownerValue.constrainBelow(typeValue, 158 | xAlignment: .left, 159 | yOffset: 1) 160 | 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/demo/views/AccountMasterHeaderView.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AccountMasterHeaderView: AccountHeaderView { 7 | 8 | var headerSubText = UILabel() 9 | var headerDownArrow = UIImageView() 10 | 11 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 12 | 13 | override func makeLayout() { 14 | super.makeLayout() 15 | headerTitle.text = "My Accounts" 16 | 17 | headerDownArrow = UIImageView(image: UIImage.sldsUtilityIcon(.chevrondown, withSize: SLDSSquareIconUtilitySmall)) 18 | 19 | self.addSubview(headerDownArrow) 20 | headerDownArrow.constrainRightOf(self.headerTitle, 21 | yAlignment: .center, 22 | xOffset: 15, 23 | yOffset: 2) 24 | 25 | headerSubText = UILabel() 26 | headerSubText.text = "5 items, sorted by Account Name" 27 | headerSubText.font = UIFont.sldsFont(.regular, with: .small) 28 | headerSubText.textColor = UIColor.sldsTextColor(.colorTextDefault) 29 | 30 | self.addSubview(headerSubText) 31 | headerSubText.constrainBelow(self.headerTitle, 32 | xAlignment: .left, 33 | yOffset: 2) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/controllers/ColorListViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 7 | 8 | class ColorListViewController: SearchController, UITableViewDelegate, UITableViewDataSource { 9 | 10 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 11 | 12 | var colors : Array = Array() 13 | var filteredColors : Array = Array() 14 | var colorTableView : UITableView! 15 | 16 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 17 | 18 | override var title: String? { 19 | didSet { 20 | super.title = self.title 21 | switch self.title! { 22 | case ColorObjectType.background.rawValue : 23 | self.colors = ApplicationModel.sharedInstance.backgroundColors 24 | case ColorObjectType.border.rawValue : 25 | self.colors = ApplicationModel.sharedInstance.borderColors 26 | case ColorObjectType.fill.rawValue : 27 | self.colors = ApplicationModel.sharedInstance.fillColors 28 | case ColorObjectType.text.rawValue : 29 | self.colors = ApplicationModel.sharedInstance.textColors 30 | default : break 31 | } 32 | self.filterString = "" 33 | } 34 | } 35 | 36 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 37 | 38 | override var filterString : String { 39 | didSet { 40 | self.filteredColors = self.colors.filter { 41 | if self.filterString == "" { 42 | return true 43 | } else { 44 | return ($0 as ColorObject).name.lowercased().range(of: filterString) != nil 45 | } 46 | } 47 | 48 | DispatchQueue.main.async { 49 | self.colorTableView.reloadData() 50 | } 51 | } 52 | } 53 | 54 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 55 | 56 | override func viewDidLoad() { 57 | super.viewDidLoad() 58 | 59 | self.view.backgroundColor = UIColor.white 60 | styleTableView() 61 | } 62 | 63 | // MARK: - Styling methods 64 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 65 | 66 | func styleTableView() { 67 | 68 | colorTableView = UITableView(frame: CGRect(x: 0, y: 40, width: self.view.frame.width, height: self.view.frame.height - 100 )) 69 | colorTableView.delegate = self 70 | colorTableView.dataSource = self 71 | colorTableView.register(ColorCell.self, forCellReuseIdentifier: "Cell") 72 | colorTableView.backgroundColor = UIColor.white 73 | self.view.addSubview(colorTableView) 74 | } 75 | 76 | // MARK: - TableView delegate 77 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 78 | 79 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 80 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! ColorCell 81 | cell.dataProvider = filteredColors[indexPath.item] 82 | return cell 83 | } 84 | 85 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 86 | 87 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 88 | return 100 89 | } 90 | 91 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 92 | 93 | func numberOfSections(in tableView: UITableView) -> Int { 94 | return 1 95 | } 96 | 97 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 98 | 99 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 100 | return filteredColors.count 101 | } 102 | 103 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 104 | 105 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 106 | let controller = ColorViewController() 107 | controller.dataProvider = self.filteredColors[indexPath.row] 108 | self.navigationController?.show(controller, sender: self) 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/controllers/FontListViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | enum FontObjectType : String { 7 | case salesforceSans = "SalesforceSans" 8 | case lato = "Lato" 9 | } 10 | 11 | class FontListViewController: UITableViewController { 12 | 13 | var fontTypes = [String]() 14 | var fontSizes = [String]() 15 | var customFonts = ["Lato-Thin.ttf", "Lato-Light.ttf", "Lato-Regular.ttf", "Lato-Semibold.ttf", "Lato-Bold.ttf"] 16 | 17 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 18 | 19 | override var title: String? { 20 | didSet { 21 | super.title = self.title 22 | if let newTitle = self.title { 23 | self.fontType = newTitle 24 | } 25 | } 26 | } 27 | 28 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 29 | 30 | var fontType: String? { 31 | get { 32 | return self.title 33 | } 34 | set { 35 | self.fontTypes.removeAll() 36 | 37 | if newValue == FontObjectType.salesforceSans.rawValue { 38 | UIFont.sldsUseDefaultFonts() 39 | repeat { 40 | if let _ = SLDSFontType.init(rawValue: fontTypes.count), 41 | let fontName = NSString.sldsFontName(fontTypes.count) { 42 | fontTypes.append(fontName.replacingOccurrences(of: "SLDSFontType", with: "")) 43 | } 44 | } while SLDSFontType.init(rawValue: fontTypes.count)?.hashValue != 0 45 | } 46 | else { 47 | for var fontName in customFonts { 48 | UIFont.sldsUse(fontName, fromBundle: "CustomFont", for: SLDSFontType.init(rawValue:fontTypes.count)!) 49 | fontName = fontName.replacingOccurrences(of: "Lato-", with: "") 50 | fontTypes.append(fontName.replacingOccurrences(of: ".ttf", with: "")) 51 | } 52 | UIColor.sldsBorderColor( .colorBorderSuccess ) 53 | } 54 | } 55 | } 56 | 57 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 58 | 59 | override func viewDidLoad() { 60 | super.viewDidLoad() 61 | self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "fontCell") 62 | 63 | // NOTE: Collecting all the Font Sizes 64 | repeat { 65 | if let _ = SLDSFontSizeType.init(rawValue: fontSizes.count), 66 | let sizeName = NSString.sldsFontSizeName(fontSizes.count) { 67 | fontSizes.append(sizeName.replacingOccurrences(of: "SLDSFontSize", with: "")) 68 | } 69 | } while SLDSFontSizeType.init(rawValue: fontSizes.count)?.hashValue != 0 70 | } 71 | 72 | override func viewWillAppear(_ animated: Bool) { 73 | super.viewWillAppear(animated) 74 | UIFont.sldsUseDefaultFonts() 75 | self.fontType = self.title 76 | } 77 | 78 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 79 | 80 | override func didReceiveMemoryWarning() { 81 | super.didReceiveMemoryWarning() 82 | // Dispose of any resources that can be recreated. 83 | } 84 | 85 | // MARK: - Table view data source 86 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 87 | 88 | override func numberOfSections(in tableView: UITableView) -> Int { 89 | return fontTypes.count 90 | } 91 | 92 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 93 | 94 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 95 | return fontSizes.count 96 | } 97 | 98 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 99 | 100 | override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 101 | return 36.0 102 | } 103 | 104 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 105 | 106 | override func tableView(_ tableView: UITableView, indentationLevelForRowAt indexPath: IndexPath) -> Int { 107 | return 2 108 | } 109 | 110 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 111 | 112 | override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 113 | return SectionHeaderView() 114 | } 115 | 116 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 117 | 118 | override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 119 | return fontTypes[section] 120 | } 121 | 122 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 123 | 124 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 125 | let cell = tableView.dequeueReusableCell(withIdentifier: "fontCell", for: indexPath) 126 | cell.textLabel?.text = fontSizes[indexPath.row] 127 | cell.textLabel?.font = UIFont.sldsFont(SLDSFontType.init(rawValue: indexPath.section)!, with:SLDSFontSizeType.init(rawValue:indexPath.row)!) 128 | return cell 129 | } 130 | 131 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 132 | 133 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 134 | let controller = FontViewController() 135 | controller.dataProvider = indexPath 136 | self.navigationController?.pushViewController(controller, animated: true) 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/controllers/FontViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class FontViewController: UIViewController { 7 | 8 | var sampleText = UILabel() 9 | var fontInfo = UITextView() 10 | var codeView = CodeView() 11 | 12 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 13 | 14 | var dataProvider = IndexPath(row: 0, section: 0) { 15 | didSet { 16 | let sizeIndex = SLDSFontSizeType(rawValue: self.dataProvider.row)! 17 | var fontSizeName = NSString.sldsFontSizeName(sizeIndex.rawValue)! 18 | 19 | let typeIndex = SLDSFontType(rawValue: self.dataProvider.section)! 20 | var fontTypeName = NSString.sldsFontName(typeIndex.rawValue)! 21 | self.sampleText.font = UIFont.sldsFont(SLDSFontType(rawValue: self.dataProvider.section)!, 22 | with: SLDSFontSizeType(rawValue: self.dataProvider.row)!) 23 | 24 | UIFont.sldsUseDefaultFonts() 25 | fontInfo.text = "\(fontTypeName)\n \(fontSizeName)" 26 | self.codeView.objCParameters = ["UIFont","sldsFont", fontTypeName,"withSize",fontSizeName] 27 | 28 | fontSizeName = fontSizeName.trimPrefix("SLDSFontSize") 29 | fontTypeName = fontTypeName.trimPrefix("SLDSFontType") 30 | self.codeView.swiftParameters = ["UIFont","sldsFont", fontTypeName,"with",fontSizeName] 31 | } 32 | } 33 | 34 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 35 | 36 | override func viewDidLoad() { 37 | super.viewDidLoad() 38 | 39 | self.edgesForExtendedLayout = [] 40 | self.view.backgroundColor = UIColor.white 41 | 42 | self.sampleText.text = "AaBbCc" 43 | self.sampleText.textAlignment = .center 44 | self.sampleText.contentMode = .center 45 | self.sampleText.textColor = UIColor.sldsTextColor(.colorTextDefault) 46 | self.sampleText.backgroundColor = UIColor.clear 47 | self.view.addSubview(self.sampleText) 48 | 49 | self.fontInfo.textAlignment = .center 50 | self.fontInfo.isEditable = false 51 | self.fontInfo.backgroundColor = UIColor.clear 52 | self.fontInfo.textColor = UIColor.sldsTextColor(.colorTextDefault) 53 | self.fontInfo.font = UIFont.sldsFont(.regular, with: .small) 54 | self.view.addSubview(self.fontInfo) 55 | 56 | self.view.addSubview(codeView) 57 | 58 | self.view.constrainChild(self.sampleText, 59 | xAlignment: .center, 60 | yAlignment: .top, 61 | yOffset: 70) 62 | 63 | self.fontInfo.constrainBelow(self.sampleText, 64 | xAlignment: .center, 65 | width: 200, 66 | height: 150, 67 | yOffset: 10) 68 | 69 | self.view.constrainChild(self.codeView, 70 | xAlignment: .center, 71 | yAlignment: .bottom, 72 | width: self.view.frame.width, 73 | height: self.view.frame.height/3) 74 | } 75 | 76 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 77 | 78 | override func didReceiveMemoryWarning() { 79 | super.didReceiveMemoryWarning() 80 | } 81 | 82 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 83 | 84 | } 85 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/controllers/IconListViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | class IconListViewController: SearchController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource { 5 | 6 | var collectionView : UICollectionView! 7 | var icons = [IconObject]() 8 | var filteredIcons = [IconObject]() 9 | 10 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 11 | 12 | var utility : Bool { 13 | return self.title == IconObjectType.utility.rawValue 14 | } 15 | 16 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 17 | 18 | override var filterString : String { 19 | didSet { 20 | self.filteredIcons = self.icons.filter { 21 | if self.filterString == "" { 22 | return true 23 | } else { 24 | return ($0 as IconObject).name.lowercased().range(of: filterString) != nil 25 | } 26 | } 27 | 28 | DispatchQueue.main.async { 29 | self.collectionView.reloadData() 30 | } 31 | } 32 | } 33 | 34 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 35 | 36 | override var title: String? { 37 | didSet { 38 | super.title = self.title 39 | switch self.title! { 40 | case IconObjectType.action.rawValue : 41 | self.icons = ApplicationModel.sharedInstance.actionIcons 42 | case IconObjectType.custom.rawValue : 43 | self.icons = ApplicationModel.sharedInstance.customIcons 44 | case IconObjectType.standard.rawValue : 45 | self.icons = ApplicationModel.sharedInstance.standardIcons 46 | case IconObjectType.utility.rawValue : 47 | self.icons = ApplicationModel.sharedInstance.utilityIcons 48 | default : break 49 | } 50 | self.filterString = "" 51 | } 52 | } 53 | 54 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 55 | 56 | override func viewDidLoad() { 57 | super.viewDidLoad() 58 | self.view.backgroundColor = UIColor.white 59 | 60 | let backImg = UIImage.sldsUtilityIcon(.chevronleft, withSize: SLDSSquareIconUtilityLarge) 61 | self.navigationItem.backBarButtonItem?.setBackgroundImage(backImg, for: .normal, barMetrics: .default) 62 | 63 | styleCollectionView() 64 | } 65 | 66 | // MARK: Styling methods 67 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 68 | 69 | func styleCollectionView() { 70 | let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() 71 | layout.sectionInset = UIEdgeInsets(top: 0, left: 15, bottom: 15, right: 15) 72 | layout.itemSize = CGSize(width: 60, height: 60) 73 | 74 | collectionView = UICollectionView(frame: CGRect(x: 0, y: 40, width: self.view.frame.width, height: self.view.frame.height - 90), collectionViewLayout: layout) 75 | collectionView.dataSource = self 76 | collectionView.delegate = self 77 | collectionView.isAccessibilityElement = false 78 | collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "iconCell") 79 | collectionView.backgroundColor = UIColor.white 80 | self.view.addSubview(collectionView) 81 | } 82 | 83 | // MARK: UICollectionViewDataSource implementation 84 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 85 | 86 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 87 | return filteredIcons.count 88 | } 89 | 90 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 91 | 92 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 93 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "iconCell", for: indexPath as IndexPath) 94 | 95 | let iconObj = filteredIcons[indexPath.item] 96 | 97 | cell.backgroundView = UIImageView(image:iconObj.getImage()) 98 | cell.accessibilityLabel = iconObj.name 99 | cell.isAccessibilityElement = true 100 | cell.backgroundView?.contentMode = .center 101 | 102 | return cell 103 | } 104 | 105 | // MARK: UICollectionViewDelegateFlowLayout implementation 106 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 107 | 108 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 109 | let controller = IconViewController() 110 | controller.dataProvider = filteredIcons[indexPath.item] 111 | self.navigationController?.show(controller, sender: self) 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/controllers/IconViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class IconViewController: UIViewController { 7 | 8 | var iconSmall = UIImageView() 9 | var iconMedium = UIImageView() 10 | var iconLarge = UIImageView() 11 | var iconInfo = UILabel() 12 | var codeView = CodeView() 13 | 14 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 15 | 16 | var dataProvider : IconObject? { 17 | didSet { 18 | guard var data = self.dataProvider else { 19 | return 20 | } 21 | 22 | data.size = SLDSSquareIconSmall 23 | iconSmall = UIImageView(image: data.getImage()) 24 | 25 | data.size = SLDSSquareIconMedium 26 | iconMedium = UIImageView(image: data.getImage()) 27 | 28 | data.size = SLDSSquareIconLarge 29 | iconLarge = UIImageView(image: data.getImage()) 30 | 31 | self.iconInfo.text = data.name 32 | 33 | var swiftName = data.name 34 | switch data.type { 35 | case .action : 36 | swiftName = swiftName.trimPrefix("SLDSAction") 37 | 38 | case .custom : 39 | swiftName = swiftName.trimPrefix("SLDS") 40 | 41 | case .standard : 42 | swiftName = swiftName.trimPrefix("SLDSStandard") 43 | 44 | case .utility : 45 | swiftName = swiftName.trimPrefix("SLDSUtility") 46 | } 47 | 48 | self.codeView.objCParameters = ["UIImage", data.method, data.name, "withSize", "SLDSSquareIconMedium"] 49 | self.codeView.swiftParameters = ["UIImage", data.method, swiftName, "withSize", "SLDSSquareIconMedium"] 50 | } 51 | } 52 | 53 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 54 | 55 | override func viewDidLoad() { 56 | super.viewDidLoad() 57 | self.edgesForExtendedLayout = [] 58 | self.view.backgroundColor = UIColor.white 59 | 60 | self.iconInfo.textAlignment = .center 61 | self.iconInfo.textColor = UIColor.sldsTextColor(.colorTextDefault) 62 | self.iconInfo.font = UIFont.sldsFont(.regular, with: .small) 63 | self.view.addSubview(self.iconInfo) 64 | 65 | self.view.addSubview(codeView) 66 | self.view.constrainChild(self.codeView, 67 | xAlignment: .center, 68 | yAlignment: .bottom, 69 | width: self.view.frame.width, 70 | height: self.view.frame.height/3) 71 | 72 | self.view.addSubview(iconSmall) 73 | self.view.addSubview(iconMedium) 74 | self.view.addSubview(iconLarge) 75 | 76 | self.view.constrainChild(iconMedium, 77 | xAlignment: .center, 78 | yAlignment: .top, 79 | xOffset: -10, 80 | yOffset: 70) 81 | 82 | iconSmall.constrainLeftOf(iconMedium, 83 | yAlignment: .center, 84 | xOffset: 30) 85 | 86 | iconLarge.constrainRightOf(iconMedium, 87 | yAlignment: .center, 88 | xOffset: 30) 89 | 90 | self.view.constrainChild(self.iconInfo, 91 | xAlignment: .center, 92 | yAlignment: .top, 93 | yOffset: 140) 94 | } 95 | 96 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 97 | 98 | override func didReceiveMemoryWarning() { 99 | super.didReceiveMemoryWarning() 100 | } 101 | 102 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 103 | 104 | } 105 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/controllers/LibraryListViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | struct TableData { 7 | var sectionTitle: String 8 | var rows: [(name:String,type:UIViewController.Type)] 9 | } 10 | 11 | class LibraryListViewController: UITableViewController { 12 | 13 | var tableData : [TableData] { 14 | return [ 15 | TableData(sectionTitle: "Icons", 16 | rows: [(IconObjectType.action.rawValue, IconListViewController.self), 17 | (IconObjectType.custom.rawValue, IconListViewController.self), 18 | (IconObjectType.standard.rawValue, IconListViewController.self), 19 | (IconObjectType.utility.rawValue, IconListViewController.self)]), 20 | 21 | TableData(sectionTitle: "Colors", 22 | rows: [(ColorObjectType.background.rawValue, ColorListViewController.self), 23 | (ColorObjectType.border.rawValue, ColorListViewController.self), 24 | (ColorObjectType.fill.rawValue, ColorListViewController.self), 25 | (ColorObjectType.text.rawValue, ColorListViewController.self)]), 26 | 27 | TableData(sectionTitle: "Fonts", 28 | rows: [(FontObjectType.salesforceSans.rawValue, FontListViewController.self), 29 | (FontObjectType.lato.rawValue, FontListViewController.self)]) 30 | ] 31 | } 32 | 33 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 34 | 35 | override func viewDidLoad() { 36 | super.viewDidLoad() 37 | self.title = "Library" 38 | self.view.backgroundColor = UIColor.white 39 | self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell") 40 | } 41 | 42 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 43 | 44 | override func viewWillAppear(_ animated: Bool) { 45 | UIFont.sldsUseDefaultFonts() 46 | navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white, 47 | NSFontAttributeName: UIFont.sldsFont(.regular, with: .medium)] 48 | 49 | navigationItem.backBarButtonItem?.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.white, 50 | NSFontAttributeName: UIFont.sldsFont(.regular, with: .medium)], 51 | for: UIControlState.normal) 52 | 53 | super.viewWillAppear(animated) 54 | } 55 | 56 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 57 | 58 | override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 59 | return 36.0 60 | } 61 | 62 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 63 | 64 | override func numberOfSections(in tableView: UITableView) -> Int { 65 | return tableData.count 66 | } 67 | 68 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 69 | 70 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 71 | return tableData[section].rows.count 72 | } 73 | 74 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 75 | 76 | override func tableView(_ tableView: UITableView, indentationLevelForRowAt indexPath: IndexPath) -> Int { 77 | return 2 78 | } 79 | 80 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 81 | 82 | override func tableView (_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView { 83 | return SectionHeaderView() 84 | } 85 | 86 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 87 | 88 | override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 89 | return tableData[section].sectionTitle 90 | } 91 | 92 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 93 | 94 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 95 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 96 | cell.accessoryType = UITableViewCellAccessoryType.disclosureIndicator 97 | if let label = cell.textLabel { 98 | label.font = UIFont.sldsFont(.regular, with: .medium) 99 | label.text = tableData[indexPath.section].rows[indexPath.row].name 100 | label.accessibilityLabel = label.text! + tableData[indexPath.section].sectionTitle 101 | } 102 | return cell 103 | } 104 | 105 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 106 | 107 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 108 | let controllerClass = tableData[indexPath.section].rows[indexPath.row].type 109 | let controller = controllerClass.init() 110 | controller.title = tableData[indexPath.section].rows[indexPath.row].name 111 | self.navigationController?.show(controller, sender: self) 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/controls/ItemBar.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | protocol ItemBarDelegate { 7 | 8 | func itemBar(_ itemBar: ItemBar, didSelectItemAt index: NSInteger) 9 | } 10 | 11 | class ItemBar: UIControl { 12 | 13 | var items = Array() 14 | var delegate : ItemBarDelegate? 15 | 16 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 17 | 18 | var selectedIndex : Int = 0 { 19 | didSet { 20 | if let d = self.delegate { 21 | d.itemBar(self, didSelectItemAt: selectedIndex) 22 | } 23 | } 24 | } 25 | 26 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 27 | 28 | var itemWidth : CGFloat { 29 | return self.frame.width / CGFloat(self.items.count) 30 | } 31 | 32 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 33 | 34 | override init (frame : CGRect) { 35 | super.init(frame : frame) 36 | self.loadView() 37 | } 38 | 39 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 40 | 41 | convenience init () { 42 | self.init(frame:CGRect.zero) 43 | } 44 | 45 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 46 | 47 | required init(coder aDecoder: NSCoder) { 48 | fatalError("This class does not support NSCoding") 49 | } 50 | 51 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 52 | 53 | func loadView() { 54 | self.backgroundColor = UIColor.white 55 | } 56 | 57 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 58 | 59 | override func layoutSubviews() { 60 | super.layoutSubviews() 61 | 62 | for item in self.items { 63 | item.heightConstraint.constant = self.frame.height 64 | item.widthConstraint.constant = self.itemWidth 65 | } 66 | } 67 | 68 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 69 | 70 | func didSelectItemAt(sender: UIControl) { 71 | if let index = items.index(of: sender) { 72 | self.selectedIndex = index 73 | } 74 | } 75 | 76 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 77 | 78 | func removeItems() { 79 | for item in self.items { 80 | item.removeFromSuperview() 81 | } 82 | self.items.removeAll() 83 | } 84 | 85 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 86 | 87 | func addItem(item : UIControl) { 88 | self.addSubview(item) 89 | 90 | if items.count > 0 { 91 | item.constrainRightOf(items.last!, 92 | yAlignment: .bottom) 93 | 94 | } else { 95 | self.constrainChild(item, 96 | xAlignment: .left, 97 | yAlignment: .bottom) 98 | } 99 | 100 | self.items.append(item) 101 | item.addTarget(self, action: #selector(ItemBar.didSelectItemAt(sender:)), for: .touchUpInside) 102 | self.layoutIfNeeded() 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/controls/TabBar.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class TabBar: ItemBar { 7 | 8 | var underscore = UIView() 9 | 10 | override var selectedIndex: Int { 11 | didSet { 12 | self.moveUnderscore(self.selectedIndex) 13 | } 14 | } 15 | 16 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 17 | 18 | override var itemWidth : CGFloat { 19 | return self.frame.width / CGFloat(self.items.count) 20 | } 21 | 22 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 23 | 24 | override func draw(_ rect: CGRect) { 25 | let aPath = UIBezierPath() 26 | 27 | aPath.move(to: CGPoint(x:0, y:self.frame.height)) 28 | aPath.addLine(to: CGPoint(x:self.frame.width, y:self.frame.height)) 29 | aPath.close() 30 | aPath.lineWidth = 2.0 31 | UIColor.sldsTextColor(.colorTextLinkActive).set() 32 | aPath.stroke() 33 | } 34 | 35 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 36 | 37 | override func loadView() { 38 | super.loadView() 39 | self.accessibilityTraits = UIAccessibilityTraitTabBar 40 | self.underscore.backgroundColor = UIColor.sldsBorderColor(.colorBorderSelection) 41 | self.addSubview(self.underscore) 42 | 43 | self.constrainChild(self.underscore, 44 | xAlignment: .left, 45 | yAlignment: .bottom, 46 | height: 3) 47 | } 48 | 49 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 50 | 51 | override func layoutSubviews() { 52 | super.layoutSubviews() 53 | 54 | if self.underscore.widthConstraint.constant != self.itemWidth { 55 | self.underscore.widthConstraint.constant = self.itemWidth 56 | self.moveUnderscore(self.selectedIndex, animated: false) 57 | } 58 | } 59 | 60 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 61 | 62 | func addTab(withLabelString labelString :String) { 63 | let tab = UIButton() 64 | tab.setTitle(labelString.uppercased(), for: .normal) 65 | tab.titleLabel?.font = UIFont.sldsFont(.regular, with: .small) 66 | tab.setTitleColor(UIColor.sldsTextColor(.colorTextDefault), for: .normal) 67 | super.addItem(item: tab) 68 | } 69 | 70 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 71 | 72 | func moveUnderscore(_ index : Int, animated:Bool = true) { 73 | for c in self.constraints { 74 | if c.firstItem as! NSObject == underscore, 75 | c.firstAttribute == .left { 76 | c.constant = CGFloat(index) * self.itemWidth 77 | } 78 | } 79 | 80 | if animated { 81 | UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseOut, animations: { 82 | self.layoutIfNeeded() 83 | }) 84 | } 85 | else 86 | { 87 | self.layoutIfNeeded() 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/extensions/String+TrimPrefix.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | extension String { 7 | 8 | func trimPrefix(_ prefix: String) -> String { 9 | var newName = self.replacingOccurrences(of: prefix, with: "") 10 | let first = String(newName.characters.prefix(1)).lowercased() 11 | var second = String(newName.characters.prefix(2).dropFirst()) 12 | 13 | // NOTE : Special case for enums starting with XX 14 | if second == "X" { 15 | second = second.lowercased() 16 | } 17 | 18 | return first + second + String(newName.characters.dropFirst(2)) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/model/ApplicationModel.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class ApplicationModel: NSObject { 7 | 8 | static let sharedInstance = ApplicationModel() 9 | 10 | var showSwift : Bool = true 11 | 12 | // MARK: Color data management 13 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 14 | 15 | var backgroundColors : Array { 16 | return self.colorsFor(.background, first: SLDSBackgroundColorTypeFirst, last: SLDSBackgroundColorTypeLast) 17 | } 18 | 19 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 20 | 21 | var borderColors : Array { 22 | return self.colorsFor(.border, first: SLDSBorderColorTypeFirst, last:SLDSBorderColorTypeLast) 23 | } 24 | 25 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 26 | 27 | var fillColors : Array { 28 | return self.colorsFor(.fill, first: SLDSFillTypeFirst, last:SLDSFillTypeLast) 29 | } 30 | 31 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 32 | 33 | var textColors : Array { 34 | return self.colorsFor(.text, first: SLDSTextColorTypeFirst, last: SLDSTextColorTypeLast) 35 | } 36 | 37 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 38 | 39 | private func sortHue ( c1: ColorObject, c2: ColorObject ) -> Bool { 40 | var h1:CGFloat = 0.0 41 | var s1:CGFloat = 0.0 42 | var b1:CGFloat = 0.0 43 | var a1:CGFloat = 0.0 44 | 45 | var h2:CGFloat = 0.0 46 | var s2:CGFloat = 0.0 47 | var b2:CGFloat = 0.0 48 | var a2:CGFloat = 0.0 49 | 50 | c1.color?.getHue(&h1, saturation: &s1, brightness: &b1, alpha: &a1) 51 | c2.color?.getHue(&h2, saturation: &s2, brightness: &b2, alpha: &a2) 52 | 53 | if a1 >= a2 - 0.05 || a1 < a2 + 0.05 { 54 | if h1 == h2 { 55 | if s1 >= s2 - 0.05 || s1 < s2 + 0.05 { 56 | return b2 < b1 57 | } else { 58 | return s1 < s2 59 | } 60 | } else { 61 | return h1 < h2 62 | } 63 | } else { 64 | return a1 < a2 65 | } 66 | } 67 | 68 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 69 | 70 | private func colorsFor(_ type: ColorObjectType, first:NSInteger, last:NSInteger ) -> Array { 71 | 72 | var colorList = Array() 73 | 74 | for index in first...last { 75 | let color = ColorObject(type: type, index: index) 76 | colorList.append(color) 77 | } 78 | 79 | return colorList.sorted(by: self.sortHue) 80 | } 81 | 82 | // MARK: Icon data management 83 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 84 | 85 | var actionIcons : Array { 86 | return self.iconsFor( .action, first: SLDSActionIconTypeFirst, last: SLDSActionIconTypeLast ) 87 | } 88 | 89 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 90 | 91 | var customIcons : Array { 92 | return self.iconsFor( .custom, first: SLDSCustomIconTypeFirst, last: SLDSCustomIconTypeLast ) 93 | } 94 | 95 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 96 | 97 | var standardIcons : Array { 98 | return self.iconsFor( .standard, first: SLDSStandardIconTypeFirst, last: SLDSStandardIconTypeLast ) 99 | } 100 | 101 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 102 | 103 | var utilityIcons : Array { 104 | return self.iconsFor( .utility, first: SLDSUtilityIconTypeFirst, last: SLDSUtilityIconTypeLast ) 105 | } 106 | 107 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 108 | 109 | private func iconsFor(_ type : IconObjectType, first:NSInteger, last:NSInteger ) -> Array { 110 | 111 | var iconList = Array() 112 | 113 | for index in first...last { 114 | let icon = IconObject(type: type, index: index, size: SLDSSquareIconMedium) 115 | iconList.append(icon) 116 | } 117 | 118 | return iconList 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/model/ColorObject.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 7 | 8 | enum ColorObjectType : String { 9 | case background = "Background" 10 | case border = "Border" 11 | case fill = "Fill" 12 | case text = "Text" 13 | } 14 | 15 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 16 | 17 | struct ColorObject { 18 | var type : ColorObjectType 19 | var index : NSInteger 20 | 21 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 22 | 23 | var color : UIColor? { 24 | 25 | switch self.type { 26 | case .background : 27 | if let value = SLDSBackgroundColorType.init(rawValue: self.index) { 28 | return UIColor.sldsBackgroundColor(value) 29 | } 30 | 31 | case .border : 32 | if let value = SLDSBorderColorType.init(rawValue: self.index) { 33 | return UIColor.sldsBorderColor(value) 34 | } 35 | 36 | case .fill : 37 | if let value = SLDSFillType.init(rawValue: self.index) { 38 | return UIColor.sldsFill(value) 39 | } 40 | 41 | case .text : 42 | if let value = SLDSTextColorType.init(rawValue: self.index) { 43 | return UIColor.sldsTextColor(value) 44 | } 45 | } 46 | 47 | return nil 48 | } 49 | 50 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 51 | 52 | var method : String { 53 | 54 | switch self.type { 55 | case .background : 56 | return "sldsBackgroundColor" 57 | 58 | case .border : 59 | return "sldsBorderColor" 60 | 61 | case .fill : 62 | return "sldsFill" 63 | 64 | case .text : 65 | return "sldsTextColor" 66 | } 67 | } 68 | 69 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 70 | 71 | var name : String { 72 | return NSString.sldsColorName(self.index) 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/model/IconObject.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | enum IconObjectType : String { 7 | case action = "Action" 8 | case custom = "Custom" 9 | case standard = "Standard" 10 | case utility = "Utility" 11 | } 12 | 13 | struct IconObject { 14 | var type : IconObjectType 15 | var index: NSInteger 16 | var size : CGFloat = 0.0 17 | 18 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 19 | 20 | var method : String { 21 | 22 | switch self.type { 23 | case .action : 24 | return "sldsActionIcon" 25 | 26 | case .custom : 27 | return "sldsCustomIcon" 28 | 29 | case .standard : 30 | return "sldsStandardIcon" 31 | 32 | case .utility : 33 | return "sldsUtilityIcon" 34 | } 35 | } 36 | 37 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 38 | 39 | var name : String { 40 | return NSString.sldsIconName(index) 41 | } 42 | 43 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 44 | 45 | func getImage() -> UIImage? { 46 | 47 | switch self.type { 48 | case .action : 49 | if let value = SLDSActionIconType.init(rawValue: self.index) { 50 | return UIImage.sldsActionIcon(value, withSize: self.size) 51 | } 52 | 53 | case .custom : 54 | if let value = SLDSCustomIconType.init(rawValue: self.index) { 55 | return UIImage.sldsCustomIcon(value, withSize: self.size) 56 | } 57 | 58 | case .standard : 59 | if let value = SLDSStandardIconType.init(rawValue: index) { 60 | return UIImage.sldsStandardIcon(value, withSize: self.size) 61 | } 62 | 63 | case .utility : 64 | if let value = SLDSUtilityIconType.init(rawValue: self.index) { 65 | return UIImage.sldsUtilityIcon(value, with: UIColor.sldsFill(.brandActive), andSize: self.size) 66 | } 67 | } 68 | 69 | return nil 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/views/AboutCell.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class AboutCell: UITableViewCell { 7 | 8 | let sldsButton = UIButton() 9 | 10 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 11 | 12 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 13 | super.init(style: style, reuseIdentifier: reuseIdentifier) 14 | self.loadView() 15 | } 16 | 17 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 18 | 19 | required init(coder aDecoder: NSCoder) { 20 | fatalError("This class does not support NSCoding") 21 | } 22 | 23 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 24 | 25 | func loadView() { 26 | self.accessoryType = .none 27 | self.backgroundColor = UIColor.sldsBackgroundColor(.colorBackgroundSelection) 28 | 29 | sldsButton.setTitle("lightningdesignsystem.com", for: .normal) 30 | sldsButton.addTarget(self, action: #selector(browseToSLDS), for: .touchUpInside) 31 | sldsButton.titleLabel?.font = UIFont.sldsFont(.regular, with: .small) 32 | sldsButton.setTitleColor(UIColor.sldsTextColor(.colorTextLink), for: .normal) 33 | 34 | self.addSubview(sldsButton) 35 | self.constrainChild(sldsButton, xAlignment: .center, yAlignment: .bottom, yOffset:20) 36 | 37 | if let label = self.textLabel { 38 | label.text = "" 39 | label.font = UIFont.sldsFont(.regular, with: .medium) 40 | self.constrainChild(label, xAlignment: .center, yAlignment: .top,yOffset: 10) 41 | } 42 | } 43 | 44 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 45 | 46 | override func layoutSubviews() { 47 | super.layoutSubviews() 48 | sldsButton.constrainSize(width: self.contentView.frame.width, height: 20) 49 | } 50 | 51 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 52 | func browseToSLDS() { 53 | UIApplication.shared.open(URL(string: "http://lightningdesignsystem.com")!, options: [:], completionHandler: nil) 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/views/ColorCell.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class ColorCell: UITableViewCell { 7 | 8 | var color = UIColor.white 9 | var swatch = SwatchView() 10 | 11 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 12 | 13 | var dataProvider : ColorObject? { 14 | didSet { 15 | if let label = self.textLabel { 16 | label.text = dataProvider?.name.replacingOccurrences(of: "SLDSColorBackground", with: "") 17 | label.text = label.text?.replacingOccurrences(of: "SLDSColorBorder", with: "") 18 | label.text = label.text?.replacingOccurrences(of: "SLDSFill", with: "") 19 | label.text = label.text?.replacingOccurrences(of: "SLDSColorText", with: "") 20 | label.text = label.text?.replacingOccurrences(of: "SLDS", with: "") 21 | 22 | label.font = UIFont.sldsFont(.regular, with: .small) 23 | } 24 | swatch.dataProvider = dataProvider?.color 25 | } 26 | } 27 | 28 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 29 | 30 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 31 | super.init(style: style, reuseIdentifier: reuseIdentifier) 32 | self.makeLayout() 33 | } 34 | 35 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 36 | 37 | required init?(coder aDecoder: NSCoder) { 38 | super.init(coder: aDecoder) 39 | } 40 | 41 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 42 | 43 | override func setSelected(_ selected: Bool, animated: Bool) { 44 | super.setSelected(selected, animated: animated) 45 | swatch.dataProvider = dataProvider?.color; 46 | } 47 | 48 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 49 | 50 | override func setHighlighted(_ highlighted: Bool, animated: Bool) { 51 | super.setHighlighted(highlighted, animated: animated) 52 | swatch.dataProvider = dataProvider?.color; 53 | } 54 | 55 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 56 | 57 | override func layoutSubviews() { 58 | super.layoutSubviews() 59 | if let label = textLabel { 60 | var rect = label.frame 61 | rect.size.width = self.contentView.frame.width - 116 62 | label.frame = rect 63 | } 64 | } 65 | 66 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 67 | 68 | func makeLayout() { 69 | if let label = textLabel { 70 | label.lineBreakMode = .byTruncatingHead 71 | } 72 | 73 | self.selectedBackgroundView = UIView() 74 | self.selectedBackgroundView?.backgroundColor = UIColor.sldsBackgroundColor(.colorBackgroundRowSelected) 75 | 76 | self.contentView.addSubview(self.swatch) 77 | self.contentView.constrainChild(self.swatch, 78 | xAlignment: .right, 79 | yAlignment: .center, 80 | width: 70, 81 | height: 70, 82 | xOffset: 20) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/views/DemoCell.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class DemoCell: UITableViewCell { 7 | 8 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 9 | 10 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 11 | super.init(style: style, reuseIdentifier: reuseIdentifier) 12 | self.loadView() 13 | } 14 | 15 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 16 | 17 | required init(coder aDecoder: NSCoder) { 18 | fatalError("This class does not support NSCoding") 19 | } 20 | 21 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 22 | 23 | override func layoutSubviews() { 24 | super.layoutSubviews() 25 | 26 | if let label = self.textLabel { 27 | label.frame = CGRect(x: 0, y: 10, width: self.frame.width, height: 30) 28 | } 29 | } 30 | 31 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 32 | 33 | func loadView() { 34 | self.backgroundColor = UIColor.sldsFill(.brand) 35 | 36 | self.selectedBackgroundView = UIView() 37 | self.selectedBackgroundView?.backgroundColor = UIColor.sldsFill(.brand) 38 | 39 | if let label = self.textLabel { 40 | label.text = "Example App" 41 | label.textAlignment = .center 42 | label.textColor = UIColor.sldsTextColor(.colorTextInverse) 43 | label.font = UIFont.sldsFont(.regular, with: .large) 44 | } 45 | 46 | let image = UIImageView(image: UIImage(named: "exampleApp")) 47 | self.addSubview(image) 48 | self.constrainChild(image, xAlignment: .center, yAlignment: .bottom, width: 258, height: 230) 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/views/LibraryCell.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class LibraryCell: UITableViewCell { 7 | 8 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 9 | 10 | override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 11 | super.init(style: style, reuseIdentifier: reuseIdentifier) 12 | self.loadView() 13 | } 14 | 15 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 16 | 17 | 18 | required init(coder aDecoder: NSCoder) { 19 | fatalError("This class does not support NSCoding") 20 | } 21 | 22 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 23 | 24 | override func layoutSubviews() { 25 | super.layoutSubviews() 26 | 27 | if let label = self.textLabel { 28 | label.frame = CGRect(x: 0, y: 10, width: self.frame.width, height: 30) 29 | } 30 | } 31 | 32 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 33 | 34 | func loadView() { 35 | self.backgroundColor = UIColor.sldsFill(.brandActive) 36 | 37 | self.selectedBackgroundView = UIView() 38 | self.selectedBackgroundView?.backgroundColor = UIColor.sldsFill(.brandActive) 39 | 40 | if let label = self.textLabel { 41 | label.text = "Library" 42 | label.textAlignment = .center 43 | label.textColor = UIColor.sldsTextColor(.colorTextInverse) 44 | label.font = UIFont.sldsFont(.regular, with: .large) 45 | } 46 | 47 | let image = UIImageView(image: UIImage(named: "tokens")) 48 | self.addSubview(image) 49 | self.constrainChild(image, xAlignment: .center, yAlignment: .center, width: 222, height: 175, yOffset: 10) 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/views/SectionHeaderView.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 7 | 8 | class SectionHeaderView: UITableViewHeaderFooterView { 9 | 10 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 11 | 12 | override func willMove(toSuperview newSuperview: UIView?) { 13 | self.applyStyle() 14 | if let superview = newSuperview { 15 | super.willRemoveSubview(superview) 16 | } 17 | } 18 | 19 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 20 | 21 | func applyStyle() { 22 | self.textLabel?.font = UIFont.sldsFont(.regular, with: .medium) 23 | self.contentView.backgroundColor = UIColor.sldsBackgroundColor(.colorBackgroundRowActive) 24 | } 25 | 26 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Demo-Swift/slds-sample-app/library/views/SwatchView.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | import UIKit 5 | 6 | class SwatchView: UIView { 7 | 8 | var swatch = UIView() 9 | 10 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 11 | 12 | var dataProvider : UIColor? { 13 | get { 14 | return self.swatch.backgroundColor 15 | } 16 | set { 17 | self.swatch.backgroundColor = newValue 18 | self.backgroundColor = UIColor(patternImage: UIImage(named: "checkered.png")!) 19 | } 20 | } 21 | 22 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 23 | 24 | override init (frame : CGRect) { 25 | super.init(frame : frame) 26 | self.loadView() 27 | } 28 | 29 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 30 | 31 | convenience init () { 32 | self.init(frame:CGRect.zero) 33 | } 34 | 35 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 36 | 37 | required init(coder aDecoder: NSCoder) { 38 | fatalError("This class does not support NSCoding") 39 | } 40 | 41 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 42 | 43 | func loadView() { 44 | self.layer.borderWidth = 1 45 | self.layer.cornerRadius = 6 46 | self.layer.borderColor = UIColor.sldsBorderColor(.colorBorderInput).cgColor 47 | self.layer.backgroundColor = UIColor.white.cgColor 48 | 49 | self.backgroundColor = UIColor(patternImage: UIImage(named: "checkered.png")!) 50 | self.clipsToBounds = true 51 | 52 | self.addSubview(self.swatch) 53 | } 54 | 55 | //–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– 56 | 57 | override func layoutSubviews() { 58 | self.swatch.frame = self.bounds.insetBy(dx: 1.0, dy: 1.0) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /DesignSystem.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'DesignSystem' 3 | s.version = '3.2.0' 4 | s.summary = 'Salesforce Lightning Design System iOS Integration' 5 | s.authors = 'Salesforce.com and contributors' 6 | s.source = { :git => 'https://github.com/salesforce-ux/design-system-ios.git', :tag => 'v3.2.0' } 7 | s.source_files = 'SalesforceDesignSystem/*', 'SalesforceDesignSystem/Generated/**/*' 8 | s.public_header_files = 'SalesforceDesignSystem/*.h', 'SalesforceDesignSystem/Generated/**/*.h' 9 | s.resource_bundle = { 'SalesforceDesignSystem' => 'SalesforceDesignSystem.bundle/**' } 10 | s.frameworks = 'UIKit', 'CoreText' 11 | s.requires_arc = true 12 | s.homepage = 'https://www.lightningdesignsystem.com' 13 | s.license = { :type => 'Salesforce.com Lightning Design System License', :file => 'LICENSE.txt' } 14 | s.platform = :ios, '8.0' 15 | end 16 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-present, Salesforce.com, Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the Salesforce.com nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceDesignSystemIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceDesignSystemIcons.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceSans-Bold.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceSans-BoldItalic.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceSans-Italic.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceSans-Light.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceSans-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceSans-LightItalic.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceSans-Regular.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceSans-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceSans-Thin.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.bundle/SalesforceSans-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/SalesforceDesignSystem.bundle/SalesforceSans-ThinItalic.ttf -------------------------------------------------------------------------------- /SalesforceDesignSystem.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SalesforceDesignSystem.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SalesforceDesignSystem.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SalesforceDesignSystem.xcodeproj/xcshareddata/xcschemes/SalesforceDesignSystem.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /SalesforceDesignSystem.xcodeproj/xcshareddata/xcschemes/SalesforceDesignSystemNames.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /SalesforceDesignSystem/DesignSystemTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SalesforceDesignSystem/DesignSystemTests/SLDSTests.m: -------------------------------------------------------------------------------- 1 | #import "SalesforceDesignSystem.h" 2 | #import 3 | 4 | #define roundFloat(input) round(input*100)/100 5 | 6 | @interface SLDSTests : XCTestCase 7 | @end 8 | 9 | @implementation SLDSTests 10 | 11 | // COLORS 12 | //------------------------------------------------------------------- 13 | 14 | - (void)testFillAccuracy { 15 | CGFloat red, green, blue, alpha; 16 | [[UIColor sldsFill:SLDSFillBrand] getRed:&red green:&green blue:&blue alpha:&alpha]; 17 | 18 | XCTAssertEqual(roundFloat(red), 0, @"Red equal"); 19 | XCTAssertEqual(roundFloat(green), 0.44, @"Green equal"); 20 | XCTAssertEqual(roundFloat(blue), 0.82, @"Blue equal"); 21 | XCTAssertEqual(roundFloat(alpha), 1, @"Alpha equal"); 22 | } 23 | 24 | //------------------------------------------------------------------- 25 | 26 | - (void)testBackgroundColorAccuracy { 27 | CGFloat red, green, blue, alpha; 28 | [[UIColor sldsBackgroundColor:SLDSColorBackgroundInverse] getRed:&red green:&green blue:&blue alpha:&alpha]; 29 | 30 | XCTAssertEqual(roundFloat(red), 0.02, @"Red equal"); 31 | XCTAssertEqual(roundFloat(green), 0.11, @"Green equal"); 32 | XCTAssertEqual(roundFloat(blue), 0.25, @"Blue equal"); 33 | XCTAssertEqual(roundFloat(alpha), 1, @"Alpha equal"); 34 | } 35 | 36 | //------------------------------------------------------------------- 37 | 38 | - (void)testBorderColorAccuracy { 39 | CGFloat red, green, blue, alpha; 40 | [[UIColor sldsBorderColor:SLDSColorBorderButtonInverseDisabled] getRed:&red green:&green blue:&blue alpha:&alpha]; 41 | 42 | XCTAssertEqual(roundFloat(red), 1, @"Red equal"); 43 | XCTAssertEqual(roundFloat(green), 1, @"Green equal"); 44 | XCTAssertEqual(roundFloat(blue), 1, @"Blue equal"); 45 | XCTAssertEqual(roundFloat(alpha), 0.15, @"Alpha equal"); 46 | } 47 | 48 | //------------------------------------------------------------------- 49 | 50 | - (void)testTextColorAccuracy { 51 | CGFloat red, green, blue, alpha; 52 | [[UIColor sldsTextColor:SLDSColorTextError] getRed:&red green:&green blue:&blue alpha:&alpha]; 53 | 54 | XCTAssertEqual(roundFloat(red), 0.76, @"Red equal"); 55 | XCTAssertEqual(roundFloat(green), 0.22, @"Green equal"); 56 | XCTAssertEqual(roundFloat(blue), 0.2, @"Blue equal"); 57 | XCTAssertEqual(roundFloat(alpha), 1, @"Alpha equal"); 58 | } 59 | 60 | //------------------------------------------------------------------- 61 | 62 | - (void)testFillRange { 63 | UIColor *color = [UIColor sldsFill:SLDSFillTypeLast+1]; 64 | XCTAssertEqual(color, nil, @"Fill range max + 1"); 65 | 66 | color = [UIColor sldsFill:SLDSFillTypeLast+1]; 67 | XCTAssertEqual(color, nil, @"Fill range min - 1"); 68 | } 69 | 70 | //------------------------------------------------------------------- 71 | 72 | - (void)testBackgroundColorRange { 73 | UIColor *color = [UIColor sldsBackgroundColor:SLDSBackgroundColorTypeLast+1]; 74 | XCTAssertEqual(color, nil, @"Background color range max + 1"); 75 | 76 | color = [UIColor sldsBackgroundColor:SLDSBackgroundColorTypeLast+1]; 77 | XCTAssertEqual(color, nil, @"Background color range min - 1"); 78 | } 79 | 80 | //------------------------------------------------------------------- 81 | 82 | - (void)testBorderColorRange { 83 | UIColor *color = [UIColor sldsBorderColor:SLDSBorderColorTypeLast+1]; 84 | XCTAssertEqual(color, nil, @"Border color range max + 1"); 85 | 86 | color = [UIColor sldsBorderColor:SLDSBorderColorTypeLast+1]; 87 | XCTAssertEqual(color, nil, @"Border color range min - 1"); 88 | } 89 | 90 | //------------------------------------------------------------------- 91 | 92 | - (void)testTextColorRange { 93 | UIColor *color = [UIColor sldsTextColor:SLDSTextColorTypeLast+1]; 94 | XCTAssertEqual(color, nil, @"Text color range max + 1"); 95 | 96 | color = [UIColor sldsTextColor:SLDSTextColorTypeLast+1]; 97 | XCTAssertEqual(color, nil, @"Text color range min - 1"); 98 | } 99 | 100 | // ICONS 101 | //------------------------------------------------------------------- 102 | 103 | - (void)testActionIconRange { 104 | UIImage *icon = [UIImage sldsActionIcon:SLDSActionIconTypeLast+1 withSize:SLDSSizeLarge]; 105 | XCTAssertEqual(icon, nil, @"Fill range max + 1"); 106 | 107 | icon = [UIImage sldsActionIcon:SLDSActionIconTypeFirst-1 withSize:SLDSSizeLarge]; 108 | XCTAssertEqual(icon, nil, @"Fill range min - 1"); 109 | } 110 | 111 | //------------------------------------------------------------------- 112 | 113 | - (void)testCustomIconRange { 114 | UIImage *icon = [UIImage sldsCustomIcon:SLDSCustomIconTypeLast+1 withSize:SLDSSizeLarge]; 115 | XCTAssertEqual(icon, nil, @"Fill range max + 1"); 116 | 117 | icon = [UIImage sldsCustomIcon:SLDSCustomIconTypeFirst-1 withSize:SLDSSizeLarge]; 118 | XCTAssertEqual(icon, nil, @"Fill range min - 1"); 119 | } 120 | 121 | //------------------------------------------------------------------- 122 | 123 | - (void)testStandardIconRange { 124 | UIImage *icon = [UIImage sldsStandardIcon:SLDSStandardIconTypeLast+1 withSize:SLDSSizeLarge]; 125 | XCTAssertEqual(icon, nil, @"Fill range max + 1"); 126 | 127 | icon = [UIImage sldsStandardIcon:SLDSStandardIconTypeFirst-1 withSize:SLDSSizeLarge]; 128 | XCTAssertEqual(icon, nil, @"Fill range min - 1"); 129 | } 130 | 131 | //------------------------------------------------------------------- 132 | 133 | - (void)testUtilityIconRange { 134 | UIImage *icon = [UIImage sldsUtilityIcon:SLDSUtilityIconTypeLast+1 withSize:SLDSSizeLarge]; 135 | XCTAssertEqual(icon, nil, @"Fill range max + 1"); 136 | 137 | icon = [UIImage sldsUtilityIcon:SLDSUtilityIconTypeFirst-1 withSize:SLDSSizeLarge]; 138 | XCTAssertEqual(icon, nil, @"Fill range min - 1"); 139 | } 140 | 141 | // SIZING 142 | //------------------------------------------------------------------- 143 | 144 | - (void)testSizingAccuracy { 145 | XCTAssertEqual(SLDSSpacingMedium, 16, "Spacing accuracy"); 146 | XCTAssertEqual(SLDSSizeXSmall, 192, "Size accuracy"); 147 | XCTAssertEqual(SLDSSquareIconMedium, 38, "Icon size accuracy"); 148 | XCTAssertEqual(SLDSBorderRadiusMedium, 4, "Border radius accuracy"); 149 | } 150 | 151 | @end 152 | -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/Extensions/NSString+SLDSName.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import "SLDSName.h" 6 | 7 | @interface NSString (SLDSName) 8 | 9 | +(NSString*)sldsColorName:(NSInteger)colorType; 10 | +(NSString*)sldsFontName:(NSInteger)fontType; 11 | +(NSString*)sldsFontSizeName:(NSInteger)sizeType; 12 | +(NSString*)sldsIconName:(NSInteger)iconType; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/Extensions/NSString+SLDSName.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "NSString+SLDSName.h" 5 | 6 | @implementation NSString (SLDSName) 7 | 8 | //------------------------------------------------------------------- 9 | 10 | +(NSString*)sldsColorName:(NSInteger)colorType { 11 | return sldsColorTypeNames(colorType); 12 | } 13 | 14 | //------------------------------------------------------------------- 15 | 16 | +(NSString*)sldsFontName:(NSInteger)fontType { 17 | return sldsFontTypeNames(fontType); 18 | } 19 | 20 | //------------------------------------------------------------------- 21 | 22 | +(NSString*)sldsFontSizeName:(NSInteger)sizeType { 23 | return sldsFontSizeNames(sizeType); 24 | } 25 | 26 | //------------------------------------------------------------------- 27 | 28 | +(NSString*)sldsIconName:(NSInteger)iconType { 29 | return sldsIconTypeNames(iconType); 30 | } 31 | 32 | @end -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/Extensions/UIColor+SLDSColor.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import "SLDSColor.h" 6 | 7 | @interface UIColor (SLDSColor) 8 | 9 | +(instancetype)sldsFill:(SLDSFillType)colorType; 10 | +(instancetype)sldsBorderColor:(SLDSBorderColorType)colorType; 11 | +(instancetype)sldsBackgroundColor:(SLDSBackgroundColorType)colorType; 12 | +(instancetype)sldsTextColor:(SLDSTextColorType)colorType; 13 | +(instancetype)sldsColor:(SLDSColorType)colorType; 14 | 15 | 16 | +(void)sldsOverrideFill:(SLDSFillType)colorType with:(UIColor*)color; 17 | +(void)sldsOverrideBorderColor:(SLDSBorderColorType)colorType with:(UIColor*)color; 18 | +(void)sldsOverrideBackgroundColor:(SLDSBackgroundColorType)colorType with:(UIColor*)color; 19 | +(void)sldsOverrideTextColor:(SLDSTextColorType)colorType with:(UIColor*)color; 20 | +(void)sldsOverrideColor:(SLDSColorType)colorType with:(UIColor*)color; 21 | @end -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/Extensions/UIColor+SLDSColor.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "UIColor+SLDSColor.h" 5 | 6 | @implementation UIColor (SLDSColor) 7 | 8 | static NSMutableDictionary *colorCache = nil; 9 | 10 | 11 | 12 | +(instancetype)sldsFill:(SLDSFillType)colorType{ 13 | if(colorType < SLDSFillTypeFirst || colorType > SLDSFillTypeLast) { 14 | // NOTE: Index out of bounds 15 | return nil; 16 | } 17 | 18 | @synchronized(colorCache) { 19 | return [self colorForIndex:colorType]; 20 | } 21 | } 22 | 23 | //------------------------------------------------------------------- 24 | 25 | +(instancetype)sldsBorderColor:(SLDSBorderColorType)colorType{ 26 | if(colorType < SLDSBorderColorTypeFirst || colorType > SLDSBorderColorTypeLast) { 27 | // NOTE: Index out of bounds 28 | return nil; 29 | } 30 | 31 | @synchronized(colorCache) { 32 | return [self colorForIndex:colorType]; 33 | } 34 | } 35 | 36 | //------------------------------------------------------------------- 37 | 38 | +(instancetype)sldsBackgroundColor:(SLDSBackgroundColorType)colorType{ 39 | if(colorType < SLDSBackgroundColorTypeFirst || colorType > SLDSBackgroundColorTypeLast) { 40 | // NOTE: Index out of bounds 41 | return nil; 42 | } 43 | 44 | @synchronized(colorCache) { 45 | return [self colorForIndex:colorType]; 46 | } 47 | } 48 | 49 | //------------------------------------------------------------------- 50 | 51 | +(instancetype)sldsTextColor:(SLDSTextColorType)colorType{ 52 | if(colorType < SLDSTextColorTypeFirst || colorType > SLDSTextColorTypeLast) { 53 | // NOTE: Index out of bounds 54 | return nil; 55 | } 56 | 57 | @synchronized(colorCache) { 58 | return [self colorForIndex:colorType]; 59 | } 60 | } 61 | 62 | //------------------------------------------------------------------- 63 | 64 | +(instancetype)sldsColor:(SLDSColorType)colorType{ 65 | if(colorType < SLDSColorTypeFirst || colorType > SLDSColorTypeLast) { 66 | // NOTE: Index out of bounds 67 | return nil; 68 | } 69 | 70 | @synchronized(colorCache) { 71 | return [self colorForIndex:colorType]; 72 | } 73 | } 74 | 75 | //------------------------------------------------------------------- 76 | 77 | 78 | 79 | +(void)sldsOverrideFill:(SLDSFillType)colorType with:(UIColor*)color{ 80 | 81 | if (colorCache == nil) { 82 | colorCache = [[NSMutableDictionary alloc] init]; 83 | } 84 | 85 | @synchronized(colorCache) { 86 | [self overrideIndexWithColor:colorType with:color]; 87 | } 88 | } 89 | 90 | //------------------------------------------------------------------- 91 | 92 | +(void)sldsOverrideBorderColor:(SLDSBorderColorType)colorType with:(UIColor*)color{ 93 | 94 | if (colorCache == nil) { 95 | colorCache = [[NSMutableDictionary alloc] init]; 96 | } 97 | 98 | @synchronized(colorCache) { 99 | [self overrideIndexWithColor:colorType with:color]; 100 | } 101 | } 102 | 103 | //------------------------------------------------------------------- 104 | 105 | +(void)sldsOverrideBackgroundColor:(SLDSBackgroundColorType)colorType with:(UIColor*)color{ 106 | 107 | if (colorCache == nil) { 108 | colorCache = [[NSMutableDictionary alloc] init]; 109 | } 110 | 111 | @synchronized(colorCache) { 112 | [self overrideIndexWithColor:colorType with:color]; 113 | } 114 | } 115 | 116 | //------------------------------------------------------------------- 117 | 118 | +(void)sldsOverrideTextColor:(SLDSTextColorType)colorType with:(UIColor*)color{ 119 | 120 | if (colorCache == nil) { 121 | colorCache = [[NSMutableDictionary alloc] init]; 122 | } 123 | 124 | @synchronized(colorCache) { 125 | [self overrideIndexWithColor:colorType with:color]; 126 | } 127 | } 128 | 129 | //------------------------------------------------------------------- 130 | 131 | +(void)sldsOverrideColor:(SLDSColorType)colorType with:(UIColor*)color{ 132 | 133 | if (colorCache == nil) { 134 | colorCache = [[NSMutableDictionary alloc] init]; 135 | } 136 | 137 | @synchronized(colorCache) { 138 | [self overrideIndexWithColor:colorType with:color]; 139 | } 140 | } 141 | 142 | //------------------------------------------------------------------- 143 | 144 | 145 | +(void)overrideIndexWithColor:(NSInteger)index with:(UIColor*)color { 146 | 147 | if (colorCache == nil) { 148 | colorCache = [[NSMutableDictionary alloc] init]; 149 | } 150 | 151 | [colorCache setObject:color forKey:[NSNumber numberWithInteger:index]]; 152 | } 153 | 154 | //------------------------------------------------------------------- 155 | 156 | +(UIColor*)colorForIndex:(NSInteger)index { 157 | 158 | if (colorCache == nil) { 159 | colorCache = [[NSMutableDictionary alloc] init]; 160 | } 161 | 162 | UIColor *color = [colorCache objectForKey:[NSNumber numberWithInteger:index]]; 163 | 164 | if( color == nil ) { 165 | color = [UIColor colorWithRed:sldsColors[index][0] 166 | green:sldsColors[index][1] 167 | blue:sldsColors[index][2] 168 | alpha:sldsColors[index][3]]; 169 | 170 | [colorCache setObject:color forKey:[NSNumber numberWithInteger:index]]; 171 | } 172 | 173 | return color; 174 | } 175 | 176 | @end -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/Extensions/UIFont+SLDSFont.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import 6 | #import "SLDSFont.h" 7 | 8 | @interface UIFont (SLDSFont) 9 | 10 | +(instancetype)sldsFont:(SLDSFontType)fontType withSize:(SLDSFontSizeType)fontSize; 11 | +(void)sldsUseDefaultFonts; 12 | +(void)sldsUseDefaultFontFor:(SLDSFontType)fontType; 13 | +(void)sldsUseFont:(NSString *)fontFileName fromBundle:(NSString*)bundleName forType:(SLDSFontType)fontType; 14 | +(void)loadFont:(NSString *)fontFileName fromBundle:(NSString *)bundleName; 15 | 16 | // NOTE : Deprecated -------------------------------------------------------------- 17 | +(instancetype)sldsFontRegularWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 18 | +(instancetype)sldsFontItalicWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 19 | +(instancetype)sldsFontLightWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 20 | +(instancetype)sldsFontStrongWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 21 | +(instancetype)sldsFontThinWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 22 | 23 | @end -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/Extensions/UIFont+SLDSFont.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "UIFont+SLDSFont.h" 5 | 6 | #define kSLDSFontBundleName @"SalesforceDesignSystem" 7 | #define contains(str1, str2) ([str1 rangeOfString: str2 ].location != NSNotFound) 8 | 9 | @implementation UIFont (SLDSFont) 10 | 11 | +(NSMutableArray*) sldsFontOverrides 12 | { 13 | static NSMutableArray* fontOverrides = nil; 14 | if (fontOverrides == nil) 15 | { 16 | fontOverrides = [[NSMutableArray alloc] init]; 17 | [self sldsUseDefaultFonts]; 18 | } 19 | return fontOverrides; 20 | } 21 | 22 | //------------------------------------------------------------------- 23 | 24 | +(instancetype)sldsFont:(SLDSFontType)fontType withSize:(SLDSFontSizeType)fontSize 25 | { 26 | NSInteger fontSizeValue = sldsFontSizes(fontSize); 27 | NSString *fontFileName = sldsFontFileNames(fontType); 28 | NSString *bundleName = kSLDSFontBundleName; 29 | NSArray *override = [[self sldsFontOverrides] objectAtIndex:(NSUInteger)fontType]; 30 | 31 | if(override) 32 | { 33 | fontFileName = override[0]; 34 | bundleName = override[1]; 35 | } 36 | 37 | [UIFont loadFont:fontFileName fromBundle:bundleName]; 38 | 39 | // NOTE : Fonts (even custom) are automatically cached. 40 | NSArray *fontParts = [fontFileName componentsSeparatedByString:@"."]; 41 | return [UIFont fontWithName:fontParts[0] size:fontSizeValue]; 42 | } 43 | 44 | //------------------------------------------------------------------- 45 | 46 | +(void)sldsUseDefaultFonts { 47 | bool loopFlag = true; 48 | NSString *fontFileName; 49 | NSUInteger fontType = 0; 50 | NSMutableArray* overrides = [self sldsFontOverrides]; 51 | [overrides removeAllObjects]; 52 | 53 | do { 54 | @try { 55 | fontFileName = sldsFontFileNames(fontType); 56 | [overrides insertObject:@[fontFileName,kSLDSFontBundleName] atIndex:(NSUInteger)fontType]; 57 | fontType++; 58 | } 59 | @catch (NSException * e) { 60 | loopFlag = false; 61 | } 62 | } 63 | while(loopFlag); 64 | } 65 | 66 | //------------------------------------------------------------------- 67 | 68 | +(void)sldsUseDefaultFontFor:(SLDSFontType)fontType { 69 | NSString *fontFileName = sldsFontFileNames(fontType); 70 | [self sldsUseFont:fontFileName fromBundle:kSLDSFontBundleName forType:fontType]; 71 | } 72 | 73 | //------------------------------------------------------------------- 74 | 75 | +(void)sldsUseFont:(NSString *)fontFileName fromBundle:(NSString*)bundleName forType:(SLDSFontType)fontType { 76 | [[self sldsFontOverrides] replaceObjectAtIndex:(NSUInteger)fontType withObject:@[fontFileName,bundleName]]; 77 | } 78 | 79 | //------------------------------------------------------------------- 80 | 81 | +(void) loadFont:(NSString *)fontFileName fromBundle:(NSString *)bundleName { 82 | 83 | // NOTE : Defaulting to .ttf in case no extension is provided. 84 | // NOTE : Used for backward compatibility of icons. 85 | if(!contains(fontFileName, @".")) { 86 | fontFileName = [fontFileName stringByAppendingString:@".ttf"]; 87 | } 88 | 89 | NSArray *fontParts = [fontFileName componentsSeparatedByString:@"."]; 90 | 91 | if ([UIFont fontWithName:fontParts[0] size:10]) { 92 | return; 93 | } 94 | 95 | NSBundle *bundle; 96 | 97 | NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:bundleName withExtension:@"bundle"]; 98 | if(bundleURL){ 99 | bundle = [NSBundle bundleWithURL:bundleURL]; 100 | } else { 101 | bundle = [SLDSFont frameworkBundle]; 102 | } 103 | 104 | NSURL *fontURL = [bundle URLForResource:fontParts[0] withExtension:fontParts[1]]; 105 | NSData *fontData = [NSData dataWithContentsOfURL:fontURL]; 106 | 107 | CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)fontData); 108 | CGFontRef font = CGFontCreateWithDataProvider(provider); 109 | 110 | if (font) { 111 | CFErrorRef error = NULL; 112 | if (CTFontManagerRegisterGraphicsFont(font, &error) == NO) { 113 | CFStringRef errorDescription = CFErrorCopyDescription(error); 114 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:(__bridge NSString *)errorDescription userInfo:@{ NSUnderlyingErrorKey: (__bridge NSError *)error }]; 115 | } 116 | 117 | CFRelease(font); 118 | } 119 | 120 | CFRelease(provider); 121 | } 122 | 123 | // NOTE : Deprecated Below ------------------------------------------ 124 | //------------------------------------------------------------------- 125 | 126 | +(instancetype) sldsFontRegularWithSize:(SLDSFontSizeType)fontSize{ 127 | return [self sldsFont:SLDSFontTypeRegular withSize:fontSize]; 128 | } 129 | 130 | //------------------------------------------------------------------- 131 | 132 | +(instancetype) sldsFontItalicWithSize:(SLDSFontSizeType)fontSize{ 133 | return [self sldsFont:SLDSFontTypeItalic withSize:fontSize]; 134 | } 135 | 136 | //------------------------------------------------------------------- 137 | 138 | +(instancetype) sldsFontLightWithSize:(SLDSFontSizeType)fontSize{ 139 | return [self sldsFont:SLDSFontTypeLight withSize:fontSize]; 140 | } 141 | 142 | //------------------------------------------------------------------- 143 | 144 | +(instancetype) sldsFontStrongWithSize:(SLDSFontSizeType)fontSize{ 145 | return [self sldsFont:SLDSFontTypeBold withSize:fontSize]; 146 | } 147 | 148 | //------------------------------------------------------------------- 149 | 150 | +(instancetype) sldsFontThinWithSize:(SLDSFontSizeType)fontSize{ 151 | return [self sldsFont:SLDSFontTypeThin withSize:fontSize]; 152 | } 153 | 154 | //------------------------------------------------------------------- 155 | 156 | @end -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/Extensions/UIImage+SLDSIcon.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import "SLDSIcon.h" 6 | 7 | @interface UIImage (SLDSIcon) 8 | 9 | +(instancetype)sldsActionIcon:(SLDSActionIconType)iconType withSize:(CGFloat)size; 10 | +(instancetype)sldsActionIcon:(SLDSActionIconType)iconType withColor:(UIColor*)iconColor andSize:(CGFloat)size; 11 | +(instancetype)sldsActionIcon:(SLDSActionIconType)iconType withColor:(UIColor*)iconColor andBGColor:(UIColor*)bgColor andSize:(CGFloat)size; 12 | 13 | +(instancetype)sldsCustomIcon:(SLDSCustomIconType)iconType withSize:(CGFloat)size; 14 | +(instancetype)sldsCustomIcon:(SLDSCustomIconType)iconType withColor:(UIColor*)iconColor andSize:(CGFloat)size; 15 | +(instancetype)sldsCustomIcon:(SLDSCustomIconType)iconType withColor:(UIColor*)iconColor andBGColor:(UIColor*)bgColor andSize:(CGFloat)size; 16 | 17 | +(instancetype)sldsStandardIcon:(SLDSStandardIconType)iconType withSize:(CGFloat)size; 18 | +(instancetype)sldsStandardIcon:(SLDSStandardIconType)iconType withColor:(UIColor*)iconColor andSize:(CGFloat)size; 19 | +(instancetype)sldsStandardIcon:(SLDSStandardIconType)iconType withColor:(UIColor*)iconColor andBGColor:(UIColor*)bgColor andSize:(CGFloat)size; 20 | 21 | +(instancetype)sldsUtilityIcon:(SLDSUtilityIconType)iconType withSize:(CGFloat)size; 22 | +(instancetype)sldsUtilityIcon:(SLDSUtilityIconType)iconType withColor:(UIColor*)iconColor andSize:(CGFloat)size; 23 | +(instancetype)sldsUtilityIcon:(SLDSUtilityIconType)iconType withColor:(UIColor*)iconColor andBGColor:(UIColor*)bgColor andSize:(CGFloat)size; 24 | 25 | @end -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/SLDSFont.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #ifndef SLDSFont_h 6 | #define SLDSFont_h 7 | 8 | typedef NS_ENUM(NSInteger, SLDSFontSizeType) { 9 | 10 | SLDSFontSizeXSmall, 11 | SLDSFontSizeSmall, 12 | SLDSFontSizeMedium, 13 | SLDSFontSizeMediumA, 14 | SLDSFontSizeLarge, 15 | SLDSFontSizeXLarge, 16 | SLDSFontSizeXLargeA, 17 | SLDSFontSizeXxLarge, 18 | SLDSFontSizeTextXxSmall, 19 | SLDSFontSizeTextXSmall, 20 | SLDSFontSizeTextSmall, 21 | SLDSFontSizeTextMedium, 22 | SLDSFontSizeTextLarge, 23 | SLDSFontSizeTextXLarge, 24 | SLDSFontSizeHeadingXxSmall, 25 | SLDSFontSizeHeadingXSmall, 26 | SLDSFontSizeHeadingSmall, 27 | SLDSFontSizeHeadingMedium, 28 | SLDSFontSizeHeadingLarge, 29 | SLDSFontSizeHeadingXLarge, 30 | SLDSColorPickerInputCustomHexFontSize, 31 | SLDSInputStaticFontSize, 32 | SLDSPageHeaderTitleFontSize 33 | }; 34 | 35 | //------------------------------------------------------------------- 36 | 37 | typedef NS_ENUM(NSInteger, SLDSFontType) { 38 | SLDSFontTypeRegular, 39 | SLDSFontTypeItalic, 40 | SLDSFontTypeBold, 41 | SLDSFontTypeBoldItalic, 42 | SLDSFontTypeLight, 43 | SLDSFontTypeLightItalic, 44 | SLDSFontTypeThin, 45 | SLDSFontTypeThinItalic 46 | }; 47 | 48 | //------------------------------------------------------------------- 49 | 50 | #define sldsFontFileNames(enum) [@[\ 51 | @"SalesforceSans-Regular.ttf",\ 52 | @"SalesforceSans-Italic.ttf",\ 53 | @"SalesforceSans-Bold.ttf",\ 54 | @"SalesforceSans-BoldItalic.ttf",\ 55 | @"SalesforceSans-Light.ttf",\ 56 | @"SalesforceSans-LightItalic.ttf",\ 57 | @"SalesforceSans-Thin.ttf",\ 58 | @"SalesforceSans-ThinItalic.ttf"\ 59 | ] objectAtIndex:enum] 60 | 61 | //------------------------------------------------------------------- 62 | 63 | #define sldsFontSizes(enum) [[@[\ 64 | @10,\ 65 | @14,\ 66 | @16,\ 67 | @18,\ 68 | @20,\ 69 | @24,\ 70 | @25.12,\ 71 | @32,\ 72 | @10,\ 73 | @12,\ 74 | @13,\ 75 | @16,\ 76 | @18,\ 77 | @20,\ 78 | @10,\ 79 | @12,\ 80 | @14,\ 81 | @18,\ 82 | @24,\ 83 | @32,\ 84 | @12,\ 85 | @13,\ 86 | @18,\ 87 | ] objectAtIndex:enum] integerValue] 88 | 89 | //------------------------------------------------------------------- 90 | 91 | @interface SLDSFont : NSObject 92 | 93 | +(NSBundle*)frameworkBundle; 94 | 95 | @end 96 | 97 | #endif /* SLDSFont_h */ -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/SLDSFont.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "SLDSFont.h" 5 | 6 | @implementation SLDSFont 7 | 8 | +(NSBundle*)frameworkBundle 9 | { 10 | NSBundle *appBundle = [NSBundle bundleForClass:[self class]]; 11 | NSString *path = [appBundle pathForResource:@"SalesforceDesignSystem" ofType:@"bundle"]; 12 | 13 | NSBundle *frameworkBundle = [NSBundle bundleWithPath:path]; 14 | return frameworkBundle; 15 | } 16 | 17 | @end -------------------------------------------------------------------------------- /SalesforceDesignSystem/Generated/SLDSSize.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #ifndef SLDSSize_h 5 | #define SLDSSize_h 6 | 7 | static const CGFloat SLDSBorderWidthThin = 1; 8 | static const CGFloat SLDSBorderWidthThick = 2; 9 | static const CGFloat SLDSBorderStrokeWidthThin = 1; 10 | static const CGFloat SLDSBorderStrokeWidthThick = 2; 11 | static const CGFloat SLDSSpacingNone = 0; 12 | static const CGFloat SLDSSpacingXxxSmall = 2; 13 | static const CGFloat SLDSSpacingXxSmall = 4; 14 | static const CGFloat SLDSSpacingXSmall = 8; 15 | static const CGFloat SLDSSpacingSmall = 12; 16 | static const CGFloat SLDSSpacingMedium = 16; 17 | static const CGFloat SLDSSpacingLarge = 24; 18 | static const CGFloat SLDSSpacingXLarge = 32; 19 | static const CGFloat SLDSSpacingXxLarge = 48; 20 | static const CGFloat SLDSComponentSpacingMargin = 0; 21 | static const CGFloat SLDSComponentSpacingPadding = 16; 22 | static const CGFloat SLDSTemplateGutters = 0; 23 | static const CGFloat SLDSTemplateProfileGutters = 0; 24 | static const CGFloat SLDSCardSpacingMargin = 16; 25 | static const CGFloat SLDSCardHeaderMargin = 0; 26 | static const CGFloat SLDSCardBodyPadding = 0; 27 | static const CGFloat SLDSCardFooterMargin = 12; 28 | static const CGFloat SLDSCardFooterPadding = 0; 29 | static const CGFloat SLDSCardWrapperSpacing = 16; 30 | static const CGFloat SLDSCardSpacingSmall = 12; 31 | static const CGFloat SLDSCardSpacingLarge = 24; 32 | static const CGFloat SLDSTableCellSpacing = 8; 33 | static const CGFloat SLDSPageHeaderSpacingMargin = 0; 34 | static const CGFloat SLDSPageHeaderSpacingPadding = 16; 35 | static const CGFloat SLDSPageHeaderSpacingRow = 12; 36 | static const CGFloat SLDSSizeXxSmall = 96; 37 | static const CGFloat SLDSSizeXSmall = 192; 38 | static const CGFloat SLDSSizeSmall = 240; 39 | static const CGFloat SLDSSizeMedium = 320; 40 | static const CGFloat SLDSSizeLarge = 400; 41 | static const CGFloat SLDSSizeXLarge = 640; 42 | static const CGFloat SLDSSizeXxLarge = 960; 43 | static const CGFloat SLDSSquareIconUtilitySmall = 16; 44 | static const CGFloat SLDSSquareIconUtilityMedium = 20; 45 | static const CGFloat SLDSSquareIconUtilityLarge = 24; 46 | static const CGFloat SLDSSquareIconLargeBoundary = 48; 47 | static const CGFloat SLDSSquareIconLargeBoundaryAlt = 80; 48 | static const CGFloat SLDSSquareIconLargeContent = 32; 49 | static const CGFloat SLDSSquareIconMedium = 38; 50 | static const CGFloat SLDSSquareIconMediumBoundary = 32; 51 | static const CGFloat SLDSSquareIconMediumBoundaryAlt = 36; 52 | static const CGFloat SLDSSquareIconMediumContent = 16; 53 | static const CGFloat SLDSSquareIconMediumContentAlt = 14; 54 | static const CGFloat SLDSSquareIconSmall = 16; 55 | static const CGFloat SLDSSquareIconSmallBoundary = 24; 56 | static const CGFloat SLDSSquareIconSmallContent = 12; 57 | static const CGFloat SLDSSquareIconXSmallBoundary = 20; 58 | static const CGFloat SLDSSquareIconXSmallContent = 8; 59 | static const CGFloat SLDSSquareIconXxSmallBoundary = 16; 60 | static const CGFloat SLDSSquareIconXxSmallContent = 14; 61 | static const CGFloat SLDSSquareIconLarge = 50; 62 | static const CGFloat SLDSHeightPill = 26; 63 | static const CGFloat SLDSBrandBandImageHeightSmall = 96; 64 | static const CGFloat SLDSBrandBandImageHeightMedium = 200; 65 | static const CGFloat SLDSBrandBandImageHeightLarge = 300; 66 | static const CGFloat SLDSBrandBandScrimHeight = 50; 67 | static const CGFloat SLDSSquareToggleSlider = 20; 68 | static const CGFloat SLDSWidthToggle = 48; 69 | static const CGFloat SLDSHeightToggle = 24; 70 | static const CGFloat SLDSColorPickerSelectorWidth = 224; 71 | static const CGFloat SLDSColorPickerSwatchesWidth = 212.8; 72 | static const CGFloat SLDSColorPickerRangeHeight = 80; 73 | static const CGFloat SLDSColorPickerSliderHeight = 24; 74 | static const CGFloat SLDSColorPickerThumbWidth = 6; 75 | static const CGFloat SLDSColorPickerRangeIndicatorSize = 12; 76 | static const CGFloat SLDSColorPickerInputCustomHexWidth = 67.2; 77 | static const CGFloat SLDSColorPickerSwatchSize = 20; 78 | static const CGFloat SLDSHeightDockedBar = 40; 79 | static const CGFloat SLDSSquareIconGlobalIdentityIcon = 20; 80 | static const CGFloat SLDSHeightContextBar = 40; 81 | static const CGFloat SLDSHeightSalesPath = 32; 82 | static const CGFloat SLDSProgressBarHeight = 2; 83 | static const CGFloat SLDSProgressRingWidth = 3; 84 | static const CGFloat SLDSSliderHandleSize = 16; 85 | static const CGFloat SLDSSliderTrackHeight = 4; 86 | static const CGFloat SLDSSliderTrackWidth = 1; 87 | static const CGFloat SLDSSplitViewWidth = 400; 88 | static const CGFloat SLDSBorderRadiusSmall = 2; 89 | static const CGFloat SLDSBorderRadiusMedium = 4; 90 | static const CGFloat SLDSBorderRadiusLarge = 8; 91 | static const CGFloat SLDSBorderRadiusPill = 240; 92 | static const CGFloat SLDSBorderRadiusCircle = 0.5; 93 | static const CGFloat SLDSButtonBorderRadius = 4; 94 | static const CGFloat SLDSTableBorderRadius = 0; 95 | static const CGFloat SLDSPageHeaderBorderRadius = 0; 96 | static const CGFloat SLDSFormLabelFontSize = 12; 97 | 98 | 99 | #endif /* SLDSSize_h */ -------------------------------------------------------------------------------- /SalesforceDesignSystem/SalesforceDesignSystem.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import "SLDSSize.h" 6 | #import "UIColor+SLDSColor.h" 7 | #import "UIFont+SLDSFont.h" 8 | #import "UIImage+SLDSIcon.h" 9 | -------------------------------------------------------------------------------- /SalesforceDesignSystem/SalesforceDesignSystemNames.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "NSString+SLDSName.h" 5 | -------------------------------------------------------------------------------- /manual_install_info/README.md: -------------------------------------------------------------------------------- 1 | ## Manual Submodule/Subproject Setup 2 | 3 | ``` 4 | git init 5 | git submodule add git@github.com:salesforce-ux/design-system-ios.git 6 | ``` 7 | 8 | Step 1. in your App target Build Settings: 9 | 'Other Linker Flags' should have: -ObjC 10 | 11 | [![browser support](/manual_install_info/linkerFlag.png)](/manual_install_info/linkerFlag.png) 12 | 13 | Step 2. in App target Build Phases: 14 | add SalesforceDesignSystem to 'Target Dependencies' 15 | 16 | [![browser support](/manual_install_info/targetDependency.png)](/manual_install_info/targetDependency.png) 17 | 18 | Step 3. in App target Build Phases: 19 | add SalesforceDesignSystem.a to 'Link Binary with Libraries' 20 | 21 | [![browser support](/manual_install_info/linkedLibrary.png)](/manual_install_info/linkedLibrary.png) 22 | 23 | Step 4. drag SalesforceDesignSystem.bundle from SalesforceDesignSystem.xcodeproj folder in the left panel to 'Copy Bundle Resources' section in Build Phases. Choose 'Create folder references' in the dialog window: 24 | 25 | [![browser support](/manual_install_info/bundleResource.png)](/manual_install_info/bundleResource.png) 26 | 27 | 28 | -------------------------------------------------------------------------------- /manual_install_info/bundleResource.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/manual_install_info/bundleResource.png -------------------------------------------------------------------------------- /manual_install_info/linkedLibrary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/manual_install_info/linkedLibrary.png -------------------------------------------------------------------------------- /manual_install_info/linkerFlag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/manual_install_info/linkerFlag.png -------------------------------------------------------------------------------- /manual_install_info/targetDependency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salesforce-ux/design-system-ios/e2f64490d78ab7ddf9e64fd125806f6bfe6142e9/manual_install_info/targetDependency.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "design-system-ios", 3 | "version": "3.2.0", 4 | "repository": "https://github.com/salesforce-ux/design-system-ios.git", 5 | "license": "SEE LICENSE IN README.md", 6 | "description": "Lightning Design System tokens, icons and fonts for iOS", 7 | "scripts": { 8 | "build": "gulp", 9 | "test": "mocha" 10 | }, 11 | "author": "Salesforce UX", 12 | "dependencies": { 13 | "@salesforce-ux/design-system": "^2.4.3", 14 | "del": "^2.2.2", 15 | "gulp": "^3.9.1", 16 | "gulp-consolidate": "^0.2.0", 17 | "gulp-data": "^1.2.1", 18 | "gulp-edit-xml": "^2.0.0", 19 | "gulp-filter": "^5.0.0", 20 | "gulp-iconfont": "^8.0.1", 21 | "gulp-json-concat": "0.0.5", 22 | "gulp-json-format": "^1.0.0", 23 | "gulp-nunjucks": "^2.3.0", 24 | "gulp-rename": "^1.2.2", 25 | "gulp-svgmin": "^1.2.3", 26 | "gulp-svgo": "^1.0.3", 27 | "gulp-yaml": "^1.0.1", 28 | "gutil": "^1.6.4", 29 | "lodash": "^4.17.4", 30 | "merge2": "^1.0.2", 31 | "mocha": "^3.2.0", 32 | "run-sequence": "^1.2.2", 33 | "theo": "^5.0.0-beta.1", 34 | "through2": "^2.0.1" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /templates/Font/SLDSFont.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #ifndef SLDSFont_h 6 | #define SLDSFont_h 7 | 8 | typedef NS_ENUM(NSInteger, SLDSFontSizeType) { 9 | {% for size in data.FontSize %} 10 | SLDS{{size.name}}{% if not loop.last %},{% endif %}{% endfor %} 11 | }; 12 | 13 | //------------------------------------------------------------------- 14 | 15 | typedef NS_ENUM(NSInteger, SLDSFontType) { 16 | SLDSFontTypeRegular, 17 | SLDSFontTypeItalic, 18 | SLDSFontTypeBold, 19 | SLDSFontTypeBoldItalic, 20 | SLDSFontTypeLight, 21 | SLDSFontTypeLightItalic, 22 | SLDSFontTypeThin, 23 | SLDSFontTypeThinItalic 24 | }; 25 | 26 | //------------------------------------------------------------------- 27 | 28 | #define sldsFontFileNames(enum) [@[\ 29 | @"SalesforceSans-Regular.ttf",\ 30 | @"SalesforceSans-Italic.ttf",\ 31 | @"SalesforceSans-Bold.ttf",\ 32 | @"SalesforceSans-BoldItalic.ttf",\ 33 | @"SalesforceSans-Light.ttf",\ 34 | @"SalesforceSans-LightItalic.ttf",\ 35 | @"SalesforceSans-Thin.ttf",\ 36 | @"SalesforceSans-ThinItalic.ttf"\ 37 | ] objectAtIndex:enum] 38 | 39 | //------------------------------------------------------------------- 40 | 41 | #define sldsFontSizes(enum) [[@[\{% for size in data.FontSize %} 42 | @{{size.value}},\{% endfor %} 43 | ] objectAtIndex:enum] integerValue] 44 | 45 | //------------------------------------------------------------------- 46 | 47 | @interface SLDSFont : NSObject 48 | 49 | +(NSBundle*)frameworkBundle; 50 | 51 | @end 52 | 53 | #endif /* SLDSFont_h */ -------------------------------------------------------------------------------- /templates/Font/SLDSFont.m.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "SLDSFont.h" 5 | 6 | @implementation SLDSFont 7 | 8 | +(NSBundle*)frameworkBundle 9 | { 10 | NSBundle *appBundle = [NSBundle bundleForClass:[self class]]; 11 | NSString *path = [appBundle pathForResource:@"SalesforceDesignSystem" ofType:@"bundle"]; 12 | 13 | NSBundle *frameworkBundle = [NSBundle bundleWithPath:path]; 14 | return frameworkBundle; 15 | } 16 | 17 | @end -------------------------------------------------------------------------------- /templates/Font/UIFont.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import 6 | #import "SLDSFont.h" 7 | 8 | @interface UIFont (SLDSFont) 9 | 10 | +(instancetype)sldsFont:(SLDSFontType)fontType withSize:(SLDSFontSizeType)fontSize; 11 | +(void)sldsUseDefaultFonts; 12 | +(void)sldsUseDefaultFontFor:(SLDSFontType)fontType; 13 | +(void)sldsUseFont:(NSString *)fontFileName fromBundle:(NSString*)bundleName forType:(SLDSFontType)fontType; 14 | +(void)loadFont:(NSString *)fontFileName fromBundle:(NSString *)bundleName; 15 | 16 | // NOTE : Deprecated -------------------------------------------------------------- 17 | +(instancetype)sldsFontRegularWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 18 | +(instancetype)sldsFontItalicWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 19 | +(instancetype)sldsFontLightWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 20 | +(instancetype)sldsFontStrongWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 21 | +(instancetype)sldsFontThinWithSize:(SLDSFontSizeType)fontSize __deprecated_msg("use method 'sldsFont:(SLDSFontStyle) withSize:(SLDSFontSize)' instead"); 22 | 23 | @end -------------------------------------------------------------------------------- /templates/Font/UIFont.m.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "UIFont+SLDSFont.h" 5 | 6 | #define kSLDSFontBundleName @"SalesforceDesignSystem" 7 | #define contains(str1, str2) ([str1 rangeOfString: str2 ].location != NSNotFound) 8 | 9 | @implementation UIFont (SLDSFont) 10 | 11 | +(NSMutableArray*) sldsFontOverrides 12 | { 13 | static NSMutableArray* fontOverrides = nil; 14 | if (fontOverrides == nil) 15 | { 16 | fontOverrides = [[NSMutableArray alloc] init]; 17 | [self sldsUseDefaultFonts]; 18 | } 19 | return fontOverrides; 20 | } 21 | 22 | //------------------------------------------------------------------- 23 | 24 | +(instancetype)sldsFont:(SLDSFontType)fontType withSize:(SLDSFontSizeType)fontSize 25 | { 26 | NSInteger fontSizeValue = sldsFontSizes(fontSize); 27 | NSString *fontFileName = sldsFontFileNames(fontType); 28 | NSString *bundleName = kSLDSFontBundleName; 29 | NSArray *override = [[self sldsFontOverrides] objectAtIndex:(NSUInteger)fontType]; 30 | 31 | if(override) 32 | { 33 | fontFileName = override[0]; 34 | bundleName = override[1]; 35 | } 36 | 37 | [UIFont loadFont:fontFileName fromBundle:bundleName]; 38 | 39 | // NOTE : Fonts (even custom) are automatically cached. 40 | NSArray *fontParts = [fontFileName componentsSeparatedByString:@"."]; 41 | return [UIFont fontWithName:fontParts[0] size:fontSizeValue]; 42 | } 43 | 44 | //------------------------------------------------------------------- 45 | 46 | +(void)sldsUseDefaultFonts { 47 | bool loopFlag = true; 48 | NSString *fontFileName; 49 | NSUInteger fontType = 0; 50 | NSMutableArray* overrides = [self sldsFontOverrides]; 51 | [overrides removeAllObjects]; 52 | 53 | do { 54 | @try { 55 | fontFileName = sldsFontFileNames(fontType); 56 | [overrides insertObject:@[fontFileName,kSLDSFontBundleName] atIndex:(NSUInteger)fontType]; 57 | fontType++; 58 | } 59 | @catch (NSException * e) { 60 | loopFlag = false; 61 | } 62 | } 63 | while(loopFlag); 64 | } 65 | 66 | //------------------------------------------------------------------- 67 | 68 | +(void)sldsUseDefaultFontFor:(SLDSFontType)fontType { 69 | NSString *fontFileName = sldsFontFileNames(fontType); 70 | [self sldsUseFont:fontFileName fromBundle:kSLDSFontBundleName forType:fontType]; 71 | } 72 | 73 | //------------------------------------------------------------------- 74 | 75 | +(void)sldsUseFont:(NSString *)fontFileName fromBundle:(NSString*)bundleName forType:(SLDSFontType)fontType { 76 | [[self sldsFontOverrides] replaceObjectAtIndex:(NSUInteger)fontType withObject:@[fontFileName,bundleName]]; 77 | } 78 | 79 | //------------------------------------------------------------------- 80 | 81 | +(void) loadFont:(NSString *)fontFileName fromBundle:(NSString *)bundleName { 82 | 83 | // NOTE : Defaulting to .ttf in case no extension is provided. 84 | // NOTE : Used for backward compatibility of icons. 85 | if(!contains(fontFileName, @".")) { 86 | fontFileName = [fontFileName stringByAppendingString:@".ttf"]; 87 | } 88 | 89 | NSArray *fontParts = [fontFileName componentsSeparatedByString:@"."]; 90 | 91 | if ([UIFont fontWithName:fontParts[0] size:10]) { 92 | return; 93 | } 94 | 95 | NSBundle *bundle; 96 | 97 | NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:bundleName withExtension:@"bundle"]; 98 | if(bundleURL){ 99 | bundle = [NSBundle bundleWithURL:bundleURL]; 100 | } else { 101 | bundle = [SLDSFont frameworkBundle]; 102 | } 103 | 104 | NSURL *fontURL = [bundle URLForResource:fontParts[0] withExtension:fontParts[1]]; 105 | NSData *fontData = [NSData dataWithContentsOfURL:fontURL]; 106 | 107 | CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)fontData); 108 | CGFontRef font = CGFontCreateWithDataProvider(provider); 109 | 110 | if (font) { 111 | CFErrorRef error = NULL; 112 | if (CTFontManagerRegisterGraphicsFont(font, &error) == NO) { 113 | CFStringRef errorDescription = CFErrorCopyDescription(error); 114 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:(__bridge NSString *)errorDescription userInfo:@{ NSUnderlyingErrorKey: (__bridge NSError *)error }]; 115 | } 116 | 117 | CFRelease(font); 118 | } 119 | 120 | CFRelease(provider); 121 | } 122 | 123 | // NOTE : Deprecated Below ------------------------------------------ 124 | //------------------------------------------------------------------- 125 | 126 | +(instancetype) sldsFontRegularWithSize:(SLDSFontSizeType)fontSize{ 127 | return [self sldsFont:SLDSFontTypeRegular withSize:fontSize]; 128 | } 129 | 130 | //------------------------------------------------------------------- 131 | 132 | +(instancetype) sldsFontItalicWithSize:(SLDSFontSizeType)fontSize{ 133 | return [self sldsFont:SLDSFontTypeItalic withSize:fontSize]; 134 | } 135 | 136 | //------------------------------------------------------------------- 137 | 138 | +(instancetype) sldsFontLightWithSize:(SLDSFontSizeType)fontSize{ 139 | return [self sldsFont:SLDSFontTypeLight withSize:fontSize]; 140 | } 141 | 142 | //------------------------------------------------------------------- 143 | 144 | +(instancetype) sldsFontStrongWithSize:(SLDSFontSizeType)fontSize{ 145 | return [self sldsFont:SLDSFontTypeBold withSize:fontSize]; 146 | } 147 | 148 | //------------------------------------------------------------------- 149 | 150 | +(instancetype) sldsFontThinWithSize:(SLDSFontSizeType)fontSize{ 151 | return [self sldsFont:SLDSFontTypeThin withSize:fontSize]; 152 | } 153 | 154 | //------------------------------------------------------------------- 155 | 156 | @end -------------------------------------------------------------------------------- /templates/Icon/SLDSIcon.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #ifndef SLDSIcon_h 6 | #define SLDSIcon_h 7 | 8 | {% for type, iconSet in icons %} 9 | typedef NS_ENUM(NSInteger, SLDS{{type | capitalize}}IconType) { 10 | {% for i in iconSet %} 11 | SLDS{{i.name}}{% if loop.first %}{% if indexName === null %} = 0{% else %} = SLDS{{indexName}} + 1{% endif %}{% endif %}{% if not loop.last %},{% endif %}{% endfor %} 12 | };{% set indexName = iconSet[iconSet.length-1].name %} 13 | static const NSInteger SLDS{{type | capitalize}}IconTypeFirst = SLDS{{iconSet[0].name}}; 14 | static const NSInteger SLDS{{type | capitalize}}IconTypeLast = SLDS{{iconSet[iconSet.length-1].name}}; 15 | 16 | //------------------------------------------------------------------- 17 | {% endfor %} 18 | static float const sldsIconBackgroundColors[][3] = { {% for type, iconSet in icons %}{% for i in iconSet %}{% if i.backgroundColor !== 'null' %} 19 | {% raw %}{{% endraw %}{{i.backgroundColor.r}},{{i.backgroundColor.g}},{{i.backgroundColor.b}}{% raw %}}{% endraw %},{% endif %}{% endfor %}{% endfor %} 20 | }; 21 | 22 | #endif /* SLDSIcon_h */ -------------------------------------------------------------------------------- /templates/Icon/UIImage.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import "SLDSIcon.h" 6 | 7 | @interface UIImage (SLDSIcon) 8 | {% for type, iconSet in icons %} 9 | +(instancetype)slds{{type | capitalize}}Icon:(SLDS{{type | capitalize}}IconType)iconType withSize:(CGFloat)size; 10 | +(instancetype)slds{{type | capitalize}}Icon:(SLDS{{type | capitalize}}IconType)iconType withColor:(UIColor*)iconColor andSize:(CGFloat)size; 11 | +(instancetype)slds{{type | capitalize}}Icon:(SLDS{{type | capitalize}}IconType)iconType withColor:(UIColor*)iconColor andBGColor:(UIColor*)bgColor andSize:(CGFloat)size; 12 | {% endfor %} 13 | @end -------------------------------------------------------------------------------- /templates/Icon/UIImage.m.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "UIImage+SLDSIcon.h" 5 | #import "UIFont+SLDSFont.h" 6 | 7 | #define sldsIconBackgroundColorsLength (sizeof sldsIconBackgroundColors) / (sizeof sldsIconBackgroundColors[0]) 8 | 9 | @implementation UIImage (SLDSIcon) 10 | 11 | static NSMutableDictionary *colorCache = nil; 12 | static NSMutableDictionary *iconCache = nil; 13 | 14 | {% set lastValue = 'empty' %}{% for type, iconSet in icons %}{% for i in icons %}{% set lastValue = i.name %}{% endfor %}{% endfor %} 15 | {% for type, iconSet in icons %} 16 | +(instancetype)slds{{type | capitalize}}Icon:(SLDS{{type | capitalize}}IconType)iconType withSize:(CGFloat)size { 17 | return [self slds{{type | capitalize}}Icon:iconType withColor:nil andBGColor:nil andSize:size]; 18 | } 19 | 20 | //------------------------------------------------------------------- 21 | 22 | +(instancetype)slds{{type | capitalize}}Icon:(SLDS{{type | capitalize}}IconType)iconType withColor:(UIColor*)iconColor andSize:(CGFloat)size { 23 | return [self slds{{type | capitalize}}Icon:iconType withColor:iconColor andBGColor:nil andSize:size]; 24 | } 25 | 26 | //------------------------------------------------------------------- 27 | 28 | +(instancetype)slds{{type | capitalize}}Icon:(SLDS{{type | capitalize}}IconType)iconType withColor:(UIColor*)iconColor andBGColor:(UIColor*)bgColor andSize:(CGFloat)size { 29 | if(iconType < SLDS{{type | capitalize}}IconTypeFirst || iconType > SLDS{{type | capitalize}}IconTypeLast) { 30 | // NOTE: Index out of bounds 31 | return nil; 32 | } 33 | 34 | @synchronized(iconCache) { 35 | return [self sldsIcon:iconType withColor:iconColor andBGColor:bgColor andSize:size]; 36 | } 37 | } 38 | 39 | //------------------------------------------------------------------- 40 | {% endfor %} 41 | 42 | +(UIColor*)colorForIndex:(NSInteger)index { 43 | static NSMutableDictionary *colorCache = nil; 44 | if (colorCache == nil) { 45 | colorCache = [[NSMutableDictionary alloc] init]; 46 | } 47 | 48 | UIColor *color = nil; 49 | 50 | if (index < sldsIconBackgroundColorsLength ) { 51 | color = [colorCache objectForKey:[NSNumber numberWithInteger:index]]; 52 | 53 | if( color == nil ) { 54 | color = [UIColor colorWithRed:sldsIconBackgroundColors[index][0] 55 | green:sldsIconBackgroundColors[index][1] 56 | blue:sldsIconBackgroundColors[index][2] 57 | alpha:1]; 58 | 59 | [colorCache setObject:color forKey:[NSNumber numberWithInteger:index]]; 60 | } 61 | } 62 | 63 | return color; 64 | } 65 | 66 | //------------------------------------------------------------------- 67 | 68 | +(UIImage*)sldsIcon:(NSInteger)iconType withColor:(UIColor*)iconColor andBGColor:(UIColor*)bgColor andSize:(CGFloat)size{ 69 | 70 | if (!iconColor) { 71 | iconColor = [UIColor whiteColor]; 72 | } 73 | if (!bgColor) { 74 | @synchronized(colorCache){ 75 | bgColor = [self colorForIndex:iconType]; 76 | } 77 | } 78 | if(!bgColor){ 79 | bgColor = [UIColor clearColor]; 80 | } 81 | 82 | static NSMutableDictionary *iconCache = nil; 83 | if (iconCache == nil) { 84 | iconCache = [[NSMutableDictionary alloc] init]; 85 | } 86 | 87 | CGFloat const *fgComps = CGColorGetComponents(iconColor.CGColor); 88 | CGFloat const * bgComps = CGColorGetComponents(bgColor.CGColor); 89 | NSString *iconKey = [NSString stringWithFormat:@"%ld%f%f%f%f%f%f%f%f%f", (long)iconType, 90 | fgComps[0], fgComps[1], fgComps[2], fgComps[3], 91 | bgComps[0], bgComps[1], bgComps[2], bgComps[3], size]; 92 | UIImage * icon = [iconCache objectForKey:iconKey]; 93 | 94 | if ( icon != nil ) { 95 | return icon; 96 | } 97 | 98 | CGSize iconSize = CGSizeMake(size,size); 99 | CGRect textRect = CGRectMake(0,(size-size)/2,size,size); 100 | UIGraphicsBeginImageContextWithOptions(iconSize, NO, 0.0f); 101 | 102 | CGContextRef ctx = UIGraphicsGetCurrentContext(); 103 | CGContextSetFillColorWithColor(ctx, bgColor.CGColor); 104 | 105 | // NOTE: Rounding ActionIcon Backgrounds 106 | CGFloat ratio = iconType >= SLDSActionIconTypeFirst && iconType <= SLDSActionIconTypeLast ? 2 : 10; 107 | 108 | UIBezierPath *bg = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, size, size) byRoundingCorners:(UIRectCornerAllCorners) cornerRadii:CGSizeMake(size/ratio, size/ratio)]; 109 | [bg fill]; 110 | 111 | UIFont *font = [UIFont fontWithName:@"SalesforceDesignSystemIcons" size:textRect.size.height]; 112 | 113 | if (font == nil) { 114 | [UIFont loadFont:@"SalesforceDesignSystemIcons" fromBundle:@"SalesforceDesignSystem"]; 115 | font = [UIFont fontWithName:@"SalesforceDesignSystemIcons" size:textRect.size.height]; 116 | } 117 | 118 | [iconColor setFill]; 119 | 120 | static NSParagraphStyle * paragraphStyle = nil; 121 | 122 | static dispatch_once_t predicate_static = 0; 123 | dispatch_once(&predicate_static, ^{ 124 | NSMutableParagraphStyle * pStyle = 125 | [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; 126 | [pStyle setAlignment:NSTextAlignmentCenter]; 127 | paragraphStyle = [pStyle copy]; 128 | }); 129 | 130 | if(font != nil){ 131 | NSString *s = [NSString stringWithFormat:@"%C", (unichar)((unsigned short)iconType + 59905)]; 132 | 133 | [s drawInRect:textRect withAttributes:@{NSFontAttributeName : font, 134 | NSForegroundColorAttributeName : iconColor, 135 | NSParagraphStyleAttributeName:paragraphStyle 136 | }]; 137 | } 138 | 139 | icon = UIGraphicsGetImageFromCurrentImageContext(); 140 | [iconCache setObject:icon forKey:iconKey]; 141 | 142 | UIGraphicsEndImageContext(); 143 | return icon; 144 | } 145 | 146 | @end -------------------------------------------------------------------------------- /templates/Name/NSString.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import "SLDSName.h" 6 | 7 | @interface NSString (SLDSName) 8 | 9 | +(NSString*)sldsColorName:(NSInteger)colorType; 10 | +(NSString*)sldsFontName:(NSInteger)fontType; 11 | +(NSString*)sldsFontSizeName:(NSInteger)sizeType; 12 | +(NSString*)sldsIconName:(NSInteger)iconType; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /templates/Name/NSString.m.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "NSString+SLDSName.h" 5 | 6 | @implementation NSString (SLDSName) 7 | 8 | //------------------------------------------------------------------- 9 | 10 | +(NSString*)sldsColorName:(NSInteger)colorType { 11 | return sldsColorTypeNames(colorType); 12 | } 13 | 14 | //------------------------------------------------------------------- 15 | 16 | +(NSString*)sldsFontName:(NSInteger)fontType { 17 | return sldsFontTypeNames(fontType); 18 | } 19 | 20 | //------------------------------------------------------------------- 21 | 22 | +(NSString*)sldsFontSizeName:(NSInteger)sizeType { 23 | return sldsFontSizeNames(sizeType); 24 | } 25 | 26 | //------------------------------------------------------------------- 27 | 28 | +(NSString*)sldsIconName:(NSInteger)iconType { 29 | return sldsIconTypeNames(iconType); 30 | } 31 | 32 | @end -------------------------------------------------------------------------------- /templates/Name/SLDSName.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #ifndef SLDSName_h 5 | #define SLDSName_h 6 | 7 | //------------------------------------------------------------------- 8 | 9 | #define sldsColorTypeNames(enum) [@[\{% for i, cat in tokenNames.Color %}{% for token in cat %} 10 | @"SLDS{{token.name}}",\{% endfor %}{% endfor %} 11 | ] objectAtIndex:enum] 12 | 13 | //------------------------------------------------------------------- 14 | 15 | #define sldsFontTypeNames(enum) [@[\ 16 | @"SLDSFontTypeRegular",\ 17 | @"SLDSFontTypeItalic",\ 18 | @"SLDSFontTypeBold",\ 19 | @"SLDSFontTypeBoldItalic",\ 20 | @"SLDSFontTypeLight",\ 21 | @"SLDSFontTypeLightItalic",\ 22 | @"SLDSFontTypeThin",\ 23 | @"SLDSFontTypeThinItalic"\ 24 | ] objectAtIndex:enum] 25 | 26 | //------------------------------------------------------------------- 27 | 28 | #define sldsFontSizeNames(enum) [@[\{% for size in tokenNames.FontSize.FontSize %} 29 | @"SLDS{{size.name}}",\{% endfor %} 30 | ] objectAtIndex:enum] 31 | 32 | //------------------------------------------------------------------- 33 | 34 | #define sldsIconTypeNames(enum) [@[\{% for name in iconNames %} 35 | @"SLDS{{name}}",\{% endfor %} 36 | ] objectAtIndex:enum] 37 | 38 | #endif /* SLDSName_h */ -------------------------------------------------------------------------------- /templates/color/SLDSColor.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #ifndef SLDSColor_h 6 | #define SLDSColor_h 7 | 8 | {% for categoryName, category in data %} 9 | typedef NS_ENUM(NSInteger, SLDS{{categoryName}}Type) { 10 | {% for v in category %} 11 | SLDS{{v.name}}{% if loop.first %}{% if indexName === null %} = 0{% else %} = SLDS{{indexName}} + 1{% endif %}{% endif %}{% if not loop.last %},{% endif %}{% endfor %} 12 | };{% set indexName = category[category.length-1].name %} 13 | static const NSInteger SLDS{{categoryName}}TypeFirst = SLDS{{category[0].name}}; 14 | static const NSInteger SLDS{{categoryName}}TypeLast = SLDS{{category[category.length-1].name}}; 15 | static const NSInteger SLDS{{categoryName}}TypeCount = SLDS{{categoryName}}TypeLast - SLDS{{categoryName}}TypeFirst; 16 | {% endfor %} 17 | 18 | static float const sldsColors[][4] = { {% for categoryName, category in data %}{% for v in category %} 19 | {% raw %}{{% endraw %}{{v.value.r}},{{v.value.g}},{{v.value.b}},{{v.value.a}}{% raw %}}{% endraw %},{% endfor %}{% endfor %} 20 | }; 21 | 22 | #endif /* SLDSColor_h */ -------------------------------------------------------------------------------- /templates/color/UIColor.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import 5 | #import "SLDSColor.h" 6 | 7 | @interface UIColor (SLDSColor) 8 | {% for categoryName, category in data %} 9 | +(instancetype)slds{{categoryName}}:(SLDS{{categoryName}}Type)colorType;{% endfor %} 10 | 11 | {% for categoryName, category in data %} 12 | +(void)sldsOverride{{categoryName}}:(SLDS{{categoryName}}Type)colorType with:(UIColor*)color;{% endfor %} 13 | @end -------------------------------------------------------------------------------- /templates/color/UIColor.m.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #import "UIColor+SLDSColor.h" 5 | 6 | @implementation UIColor (SLDSColor) 7 | 8 | static NSMutableDictionary *colorCache = nil; 9 | 10 | {% set lastValue = 'empty' %}{% for categoryName, category in data %}{% for v in category %}{% set lastValue = v.name %}{% endfor %}{% endfor %} 11 | {% for categoryName, category in data %} 12 | +(instancetype)slds{{categoryName}}:(SLDS{{categoryName}}Type)colorType{ 13 | if(colorType < SLDS{{categoryName}}TypeFirst || colorType > SLDS{{categoryName}}TypeLast) { 14 | // NOTE: Index out of bounds 15 | return nil; 16 | } 17 | 18 | @synchronized(colorCache) { 19 | return [self colorForIndex:colorType]; 20 | } 21 | } 22 | 23 | //------------------------------------------------------------------- 24 | {% endfor %} 25 | 26 | {% for categoryName, category in data %} 27 | +(void)sldsOverride{{categoryName}}:(SLDS{{categoryName}}Type)colorType with:(UIColor*)color{ 28 | 29 | if (colorCache == nil) { 30 | colorCache = [[NSMutableDictionary alloc] init]; 31 | } 32 | 33 | @synchronized(colorCache) { 34 | [self overrideIndexWithColor:colorType with:color]; 35 | } 36 | } 37 | 38 | //------------------------------------------------------------------- 39 | {% endfor %} 40 | 41 | +(void)overrideIndexWithColor:(NSInteger)index with:(UIColor*)color { 42 | 43 | if (colorCache == nil) { 44 | colorCache = [[NSMutableDictionary alloc] init]; 45 | } 46 | 47 | [colorCache setObject:color forKey:[NSNumber numberWithInteger:index]]; 48 | } 49 | 50 | //------------------------------------------------------------------- 51 | 52 | +(UIColor*)colorForIndex:(NSInteger)index { 53 | 54 | if (colorCache == nil) { 55 | colorCache = [[NSMutableDictionary alloc] init]; 56 | } 57 | 58 | UIColor *color = [colorCache objectForKey:[NSNumber numberWithInteger:index]]; 59 | 60 | if( color == nil ) { 61 | color = [UIColor colorWithRed:sldsColors[index][0] 62 | green:sldsColors[index][1] 63 | blue:sldsColors[index][2] 64 | alpha:sldsColors[index][3]]; 65 | 66 | [colorCache setObject:color forKey:[NSNumber numberWithInteger:index]]; 67 | } 68 | 69 | return color; 70 | } 71 | 72 | @end -------------------------------------------------------------------------------- /templates/size/SLDSSize.h.njk: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | #ifndef SLDSSize_h 5 | #define SLDSSize_h 6 | 7 | {% for categoryName, category in data %}{% for v in category %}static const CGFloat SLDS{{ v.name }} = {{ v.value | replace("px", "") }}; 8 | {% endfor %}{% endfor %} 9 | 10 | #endif /* SLDSSize_h */ -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-present, salesforce.com, inc. All rights reserved 2 | // Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license 3 | 4 | const assert = require('assert'); 5 | const fs = require('fs'); 6 | const _ = require('lodash'); 7 | 8 | const format = (s) => { 9 | return s[0].toUpperCase() + _.camelCase(s.substring(1)) 10 | }; 11 | 12 | const stripIconNames = (i) => { 13 | return i.filter(n => { 14 | return n.indexOf('.svg') !== -1; 15 | }).map(n => { 16 | return format(n.replace('.svg','')); 17 | }) 18 | }; 19 | 20 | let colorOutput = fs.readFileSync('./SalesforceDesignSystem/generated/SLDSColor.h').toString(); 21 | let sizeOutput = fs.readFileSync('./SalesforceDesignSystem/generated/SLDSSize.h').toString(); 22 | let iconOutput = fs.readFileSync('./SalesforceDesignSystem/generated/SLDSIcon.h').toString(); 23 | let fontOutput = fs.readFileSync('./SalesforceDesignSystem/generated/SLDSFont.h').toString(); 24 | 25 | let designTokensFile = fs.readFileSync('./node_modules/@salesforce-ux/design-system/design-tokens/dist/force-base.ios.json'); 26 | let designTokens = JSON.parse(designTokensFile.toString('utf-8')).properties; 27 | 28 | let actionIcons = stripIconNames(fs.readdirSync('./node_modules/@salesforce-ux/design-system/assets/icons/action')); 29 | let customIcons = stripIconNames(fs.readdirSync('./node_modules/@salesforce-ux/design-system/assets/icons/custom')); 30 | let standardIcons = stripIconNames(fs.readdirSync('./node_modules/@salesforce-ux/design-system/assets/icons/standard')); 31 | let utilityIcons = stripIconNames(fs.readdirSync('./node_modules/@salesforce-ux/design-system/assets/icons/utility')); 32 | 33 | let colorTokens = designTokens.filter(t => { 34 | return t.type === 'color'; 35 | }); 36 | 37 | let sizeTokens = designTokens.filter(t => { 38 | return t.type === 'size'; 39 | }); 40 | 41 | let fontSizeTokens = designTokens.filter(t => { 42 | return t.type === 'font-size'; 43 | }); 44 | 45 | describe('Color Tokens', () => { 46 | colorTokens.forEach(token => { 47 | describe(token.name, () => { 48 | it('should exist in Obj-C output (SLDSColor.h)', () => { 49 | assert(colorOutput.indexOf(token.name.charAt(0).toUpperCase() + token.name.slice(1)) !== -1) 50 | }); 51 | }); 52 | }); 53 | }); 54 | 55 | describe('Size Tokens', () => { 56 | sizeTokens.forEach(token => { 57 | describe(token.name, () => { 58 | it('should exist in Obj-C output (SLDSSize.h)', () => { 59 | assert(sizeOutput.indexOf(token.name.charAt(0).toUpperCase() + token.name.slice(1)) !== -1) 60 | }); 61 | }); 62 | }); 63 | }); 64 | 65 | describe('Font Size Tokens', () => { 66 | fontSizeTokens.forEach(token => { 67 | describe(token.name, () => { 68 | it('should exist in Obj-C output (SLDSSize.h)', () => { 69 | assert(fontOutput.indexOf(token.name.charAt(0).toUpperCase() + token.name.slice(1)) !== -1) 70 | }); 71 | }); 72 | }); 73 | }); 74 | 75 | describe('Action Icons', () => { 76 | actionIcons.forEach(icon => { 77 | describe(icon, () => { 78 | it('should exist in Obj-C output (SLDSIcon.h)', () => { 79 | assert(iconOutput.indexOf(icon) !== -1) 80 | }); 81 | }); 82 | }); 83 | }); 84 | 85 | describe('Custom Icons', () => { 86 | customIcons.forEach(icon => { 87 | describe(icon, () => { 88 | it('should exist in Obj-C output (SLDSIcon.h)', () => { 89 | assert(iconOutput.indexOf(icon) !== -1) 90 | }); 91 | }); 92 | }); 93 | }); 94 | 95 | describe('Standard Icons', () => { 96 | standardIcons.forEach(icon => { 97 | describe(icon, () => { 98 | it('should exist in Obj-C output (SLDSIcon.h)', () => { 99 | assert(iconOutput.indexOf(icon) !== -1) 100 | }); 101 | }); 102 | }); 103 | }); 104 | 105 | describe('Utility Icons', () => { 106 | utilityIcons.forEach(icon => { 107 | describe(icon, () => { 108 | it('should exist in Obj-C output (SLDSIcon.h)', () => { 109 | assert(iconOutput.indexOf(icon) !== -1) 110 | }); 111 | }); 112 | }); 113 | }); --------------------------------------------------------------------------------