-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(PosterCard): LATCH-2313 Poster card component (#413)
* feat(PosterCard): LATCH-2313 Added PosterCard, initial version * feat(PosterCard): LATCH-2313 Improving poster card * feat(PosterCard): LATCH-2313 Improving poster card * Run swiftformat * feat(PosterCard): LATCH-2313 Fixing things from review * feat(PosterCard): LATCH-2313 Fixing things from review * Run swiftformat * feat(PosterCard): LATCH-2313 Fixing things from review * feat(PosterCard): LATCH-2313 Fixing poster card and top action buttons press effects * feat(PosterCard): LATCH-2313 Fixing top actions accessibility padding to obtain 48px * Run swiftformat --------- Co-authored-by: salavert <[email protected]>
- Loading branch information
Showing
28 changed files
with
1,599 additions
and
16 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
12 changes: 12 additions & 0 deletions
12
MisticaCatalog/Source/Assets.xcassets/Samples/airpods.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "airpods.jpg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+53.1 KB
MisticaCatalog/Source/Assets.xcassets/Samples/airpods.imageset/airpods.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,97 @@ | ||
// | ||
// CardList.swift | ||
// | ||
// Made with ❤️ by Novum | ||
// | ||
// Copyright © Telefonica. All rights reserved. | ||
// | ||
|
||
import MisticaSwiftUI | ||
import SwiftUI | ||
|
||
struct CardList: View { | ||
@State var selectedFrameworkIndex = 0 | ||
let rows: [CardRow] | ||
|
||
var body: some View { | ||
List { | ||
ForEach(rows) { row in | ||
Cell( | ||
style: .fullwidth, | ||
title: row.title, | ||
subtitle: nil, | ||
description: nil, | ||
assetType: .smallIcon( | ||
Image(uiImage: row.icon), | ||
foregroundColor: nil | ||
), | ||
presetView: { CellNavigationPreset() }, | ||
headlineView: {}, | ||
destinationView: { | ||
componentView(for: row) | ||
.navigationTitle(row.title) | ||
.navigationBarTitleDisplayMode(.inline) | ||
} | ||
) | ||
.shouldShowDivider(row != rows.last) | ||
} | ||
} | ||
.misticaListStyle() | ||
} | ||
|
||
@ViewBuilder | ||
func componentView(for row: CardRow) -> some View { | ||
VStack(spacing: 0) { | ||
Tabs( | ||
Framework.allCases.map { TabItem(text: $0.name) }, | ||
selection: $selectedFrameworkIndex | ||
) | ||
|
||
switch Framework.allCases[selectedFrameworkIndex] { | ||
case .swiftUI: | ||
row.swiftUIComponent.expandVertically() | ||
case .uiKit: | ||
row.uiKitComponent.expandVertically() | ||
} | ||
} | ||
} | ||
} | ||
|
||
private extension CardRow { | ||
@ViewBuilder | ||
var swiftUIComponent: some View { | ||
switch self { | ||
case .dataCard: | ||
DataCardCatalogView() | ||
case .posterCard: | ||
PosterCardCatalogView() | ||
case .snapCard: | ||
notImplementedView | ||
} | ||
} | ||
|
||
@ViewBuilder | ||
var uiKitComponent: some View { | ||
switch self { | ||
case .dataCard: | ||
ComponentViewController(UICatalogCardsViewController()) | ||
case .posterCard, | ||
.snapCard: | ||
notImplementedView | ||
} | ||
} | ||
|
||
@ViewBuilder | ||
var notImplementedView: some View { | ||
Text("Not implemented yet") | ||
.font(.textPreset5()) | ||
.foregroundColor(.textPrimary) | ||
} | ||
} | ||
|
||
#Preview { | ||
NavigationView { | ||
CardList(rows: CardRow.allCases) | ||
} | ||
.misticaNavigationViewStyle() | ||
} |
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,39 @@ | ||
// | ||
// CardRow.swift | ||
// | ||
// Made with ❤️ by Novum | ||
// | ||
// Copyright © Telefonica. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MisticaCommon | ||
import UIKit | ||
|
||
enum CardRow: Int, CaseIterable, Identifiable { | ||
case dataCard | ||
case posterCard | ||
case snapCard | ||
|
||
var id: Int { | ||
rawValue | ||
} | ||
} | ||
|
||
extension CardRow { | ||
var title: String { | ||
switch self { | ||
case .dataCard: "Data Card" | ||
case .posterCard: "Poster Card" | ||
case .snapCard: "Snap Card" | ||
} | ||
} | ||
|
||
var icon: UIImage { | ||
switch self { | ||
case .dataCard: .cardIcon | ||
case .posterCard: .cardIcon | ||
case .snapCard: .cardIcon | ||
} | ||
} | ||
} |
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
Oops, something went wrong.