forked from microsoft/fluentui-apple
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
6 changed files
with
563 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
ios/FluentUI.Demo/FluentUI.Demo/Demos/CardViewDemoController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
13 changes: 8 additions & 5 deletions
13
....Demo/FluentUI.Demo/Resources/Assets.xcassets/PopupMenu/flag-24x24.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.