Skip to content

Commit

Permalink
Card component (microsoft#222)
Browse files Browse the repository at this point in the history
* Card Component
Card has an icon, a title and an optional subtitle. The content can be arranged in a vertical or horizontal layout.

Due to a design misunderstanding, we are now separating the cards into this component, a PreviewCard component that will look like this component but with a preview image on top, and an announcement component. This Card will be used as a Quick Action card as part of the iPad redesign work

* add support for size category changes
* dynamic text and addressed comments
* Adjust labels setup to MSFLabel
  • Loading branch information
noaMSFT authored Sep 14, 2020
1 parent 589fb25 commit e16f907
Show file tree
Hide file tree
Showing 6 changed files with 563 additions and 7 deletions.
8 changes: 6 additions & 2 deletions ios/FluentUI.Demo/FluentUI.Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
B4EF66562295F729007FEAB0 /* TableViewHeaderFooterSampleData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4EF66552295F729007FEAB0 /* TableViewHeaderFooterSampleData.swift */; };
B9450C42DB92C964C77483FF /* Pods_FluentUI_Demo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EC7D5AF5DAF7393E14BF5B28 /* Pods_FluentUI_Demo.framework */; };
C038992E2359307D00265026 /* TableViewCellShimmerDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C038992D2359307D00265026 /* TableViewCellShimmerDemoController.swift */; };
C0938E4A235F733100256251 /* ShimmerViewDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0938E49235F733100256251 /* ShimmerViewDemoController.swift */; };
C0938E4A235F733100256251 /* ShimmerLinesViewDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0938E49235F733100256251 /* ShimmerLinesViewDemoController.swift */; };
CCC18C2F2501C75F00BE830E /* CardViewDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC18C2E2501C75F00BE830E /* CardViewDemoController.swift */; };
E6842974247B672000A29C40 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6842973247B672000A29C40 /* SceneDelegate.swift */; };
E6842996247C350700A29C40 /* DemoColorThemeWindows.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6842995247C350700A29C40 /* DemoColorThemeWindows.swift */; };
FD41C8F422E28EEB0086F899 /* NavigationControllerDemoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD41C8F322E28EEB0086F899 /* NavigationControllerDemoController.swift */; };
Expand Down Expand Up @@ -106,7 +107,8 @@
B4EF66532295F1A8007FEAB0 /* TableViewHeaderFooterViewDemoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewHeaderFooterViewDemoController.swift; sourceTree = "<group>"; };
B4EF66552295F729007FEAB0 /* TableViewHeaderFooterSampleData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewHeaderFooterSampleData.swift; sourceTree = "<group>"; };
C038992D2359307D00265026 /* TableViewCellShimmerDemoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewCellShimmerDemoController.swift; sourceTree = "<group>"; };
C0938E49235F733100256251 /* ShimmerViewDemoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShimmerViewDemoController.swift; sourceTree = "<group>"; };
C0938E49235F733100256251 /* ShimmerLinesViewDemoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShimmerLinesViewDemoController.swift; sourceTree = "<group>"; };
CCC18C2E2501C75F00BE830E /* CardViewDemoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardViewDemoController.swift; sourceTree = "<group>"; };
E6842973247B672000A29C40 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
E6842995247C350700A29C40 /* DemoColorThemeWindows.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoColorThemeWindows.swift; sourceTree = "<group>"; };
E6D2996ECAAD9A81A6338783 /* Pods-FluentUI.Demo.dogfood.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FluentUI.Demo.dogfood.xcconfig"; path = "Target Support Files/Pods-FluentUI.Demo/Pods-FluentUI.Demo.dogfood.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -282,6 +284,7 @@
FDDD73FB22C6D86B00A9D995 /* ObjectiveCDemoController.m */,
B441478E228E02540040E88E /* OtherCellsDemoController.swift */,
8AF03E1F24B6BE3100E6E2A2 /* ContactCollectionViewDemoController.swift */,
CCC18C2E2501C75F00BE830E /* CardViewDemoController.swift */,
);
path = Demos;
sourceTree = "<group>";
Expand Down Expand Up @@ -474,6 +477,7 @@
B4E8F65221CD9579008A1598 /* HUDDemoController.swift in Sources */,
FD7254ED21471A3F002F4069 /* DateTimePickerDemoController.swift in Sources */,
B4EF66542295F1A8007FEAB0 /* TableViewHeaderFooterViewDemoController.swift in Sources */,
CCC18C2F2501C75F00BE830E /* CardViewDemoController.swift in Sources */,
B4575C5122FB8B6900EBD0EB /* PeoplePickerDemoController.swift in Sources */,
A5CEC21220E436F10016922A /* DemoListViewController.swift in Sources */,
B498141621E42C140077B48D /* TableViewCellDemoController.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions ios/FluentUI.Demo/FluentUI.Demo/Demos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let demos: [(title: String, controllerClass: UIViewController.Type)] = [
("BadgeField", BadgeFieldDemoController.self),
("BadgeView", BadgeViewDemoController.self),
("Button", ButtonDemoController.self),
("Card", CardViewDemoController.self),
("Color", ColorDemoController.self),
("ContactCollectionView", ContactCollectionViewDemoController.self),
("DateTimePicker", DateTimePickerDemoController.self),
Expand Down
84 changes: 84 additions & 0 deletions ios/FluentUI.Demo/FluentUI.Demo/Demos/CardViewDemoController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//

import FluentUI
import UIKit

class CardViewDemoController: DemoController {
override func viewDidLoad() {
super.viewDidLoad()

container.alignment = .leading

let demoIcon = UIImage(named: "flag-24x24")

for style in CardStyle.allCases {
addTitle(text: style.description)

switch style {
case .horizontal:
if let demoIcon = demoIcon {
let card = CardView(style: style, title: "Title", icon: demoIcon, colorStyle: .neutral)
card.delegate = self
let cardWithSubtitle = CardView(style: style, title: "Title", subtitle: "Subtitle", icon: demoIcon, colorStyle: .appColor)
cardWithSubtitle.customBackgroundColor = Colors.Button.background
cardWithSubtitle.delegate = self
let cardWithLongTitle = CardView(style: style, title: "Title that is very very very very long", icon: demoIcon, colorStyle: .appColor)
cardWithLongTitle.twoLineTitle = true
cardWithLongTitle.delegate = self
// Card with a custom background color without setting customBackgroundColor so the default background color is used
let cardLongTitleAndSubtitle = CardView(style: style, title: "Title that is very very very very long", subtitle: "Subtitle that is very long", icon: demoIcon, colorStyle: .custom)
cardLongTitleAndSubtitle.delegate = self

addRow(items: [card, cardWithSubtitle], itemSpacing: Constants.itemSpacing)
addRow(items: [cardWithLongTitle, cardLongTitleAndSubtitle], itemSpacing: Constants.itemSpacing)
}
case .vertical:
if let demoIcon = demoIcon {
let card = CardView(style: style, title: "Title", icon: demoIcon, colorStyle: .appColor)
card.delegate = self
let cardWithSubtitle = CardView(style: style, title: "Title", subtitle: "Subtitle", icon: demoIcon, colorStyle: .neutral)
cardWithSubtitle.delegate = self
let cardWithLongTitle = CardView(style: style, title: "Title that is very very very very long", icon: demoIcon, colorStyle: .custom)
cardWithLongTitle.twoLineTitle = true
cardWithLongTitle.delegate = self
let cardWithLongTitleAndSubtitle = CardView(style: style, title: "Title that is very very very very long", subtitle: "Subtitle that is very long", icon: demoIcon, colorStyle: .appColor)
cardWithLongTitleAndSubtitle.delegate = self

addRow(items: [card, cardWithSubtitle], itemSpacing: Constants.itemSpacing)
addRow(items: [cardWithLongTitle, cardWithLongTitleAndSubtitle], itemSpacing: Constants.itemSpacing)
}
}
}

container.addArrangedSubview(UIView())
}

private struct Constants {
static let itemSpacing: CGFloat = 20
}
}

extension CardStyle {
var description: String {
switch self {
case .horizontal:
return "Horizontal Card"
case .vertical:
return "Vertical Card"
}
}
}

// MARK: - CardDemoController: CardDelegate

extension CardViewDemoController: CardDelegate {
func didTapCard(_ card: CardView) {
let alert = UIAlertController(title: "Card was tapped", message: nil, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default)
alert.addAction(action)
present(alert, animated: true)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_flag_24_outlined.pdf"
"filename" : "ic_flag_24_outlined.pdf",
"idiom" : "universal"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
}
14 changes: 14 additions & 0 deletions ios/FluentUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@
C0A0D76E233AEF6C00F432FD /* ShimmerLinesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A0D76B233AEF6C00F432FD /* ShimmerLinesView.swift */; };
C0A0D76F233AEF6C00F432FD /* ShimmerLinesViewAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A0D76C233AEF6C00F432FD /* ShimmerLinesViewAppearance.swift */; };
C0EAAEAD2347E1DF00C7244E /* ShimmerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0EAAEAC2347E1DF00C7244E /* ShimmerView.swift */; };
CCC18C2C2501B22F00BE830E /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC18C2B2501B22F00BE830E /* CardView.swift */; };
CCC18C2D2501B22F00BE830E /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC18C2B2501B22F00BE830E /* CardView.swift */; };
FD053A352224CA33009B6378 /* DatePickerControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD053A342224CA33009B6378 /* DatePickerControllerTests.swift */; };
FD0D29D62151A3D700E8655E /* CardPresenterNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD0D29D52151A3D700E8655E /* CardPresenterNavigationController.swift */; };
FD1FAE1B2272464B00A5DBA4 /* GenericDateTimePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD1FAE1A2272464B00A5DBA4 /* GenericDateTimePicker.swift */; };
Expand Down Expand Up @@ -377,6 +379,7 @@
C0A0D76B233AEF6C00F432FD /* ShimmerLinesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShimmerLinesView.swift; sourceTree = "<group>"; };
C0A0D76C233AEF6C00F432FD /* ShimmerLinesViewAppearance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShimmerLinesViewAppearance.swift; sourceTree = "<group>"; };
C0EAAEAC2347E1DF00C7244E /* ShimmerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShimmerView.swift; sourceTree = "<group>"; };
CCC18C2B2501B22F00BE830E /* CardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = "<group>"; };
FD053A342224CA33009B6378 /* DatePickerControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatePickerControllerTests.swift; sourceTree = "<group>"; };
FD0D29D52151A3D700E8655E /* CardPresenterNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardPresenterNavigationController.swift; sourceTree = "<group>"; };
FD1FAE1A2272464B00A5DBA4 /* GenericDateTimePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericDateTimePicker.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -622,6 +625,7 @@
A5CEC15320D980B20016922A /* FluentUI */ = {
isa = PBXGroup;
children = (
CCC18C2A2501B1A900BE830E /* Card */,
B4F118EA21C8270F00855942 /* Badge Field */,
FDFB8AE921361C860046850A /* Calendar */,
A5CEC22F20E451990016922A /* Controls */,
Expand Down Expand Up @@ -805,6 +809,14 @@
path = Shimmer;
sourceTree = "<group>";
};
CCC18C2A2501B1A900BE830E /* Card */ = {
isa = PBXGroup;
children = (
CCC18C2B2501B22F00BE830E /* CardView.swift */,
);
path = Card;
sourceTree = "<group>";
};
FD256C5C2183D77900EC9588 /* Views */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1226,6 +1238,7 @@
8FD0119E228A82A600D25925 /* CALayer+Extensions.swift in Sources */,
637F92722501636300B5B085 /* PeoplePicker.swift in Sources */,
8FD0119F228A82A600D25925 /* Calendar+Extensions.swift in Sources */,
CCC18C2D2501B22F00BE830E /* CardView.swift in Sources */,
8FD011A1228A82A600D25925 /* CharacterSet+Extension.swift in Sources */,
FD41C8A122DD13230086F899 /* NavigationAnimator.swift in Sources */,
8FD011A2228A82A600D25925 /* Date+Extensions.swift in Sources */,
Expand Down Expand Up @@ -1358,6 +1371,7 @@
FDA1AF8F21484A26001AE720 /* Obscurable.swift in Sources */,
FD41C8A022DD13230086F899 /* NavigationAnimator.swift in Sources */,
7D23482724D88DE600FBE057 /* AvatarGroupView.swift in Sources */,
CCC18C2C2501B22F00BE830E /* CardView.swift in Sources */,
FDA1AF91214871B5001AE720 /* CardTransitionAnimator.swift in Sources */,
A5237ACD21ED6CA70040BF27 /* DrawerShadowView.swift in Sources */,
FD9DA7B5232C33A80013E41B /* UIViewController+Navigation.swift in Sources */,
Expand Down
Loading

0 comments on commit e16f907

Please sign in to comment.