Merge pull request #2981 from omnivore-app/feat/label-flair

First pass at label flair for iOS and Android
This commit is contained in:
Jackson Harper
2023-10-24 12:42:57 +08:00
committed by GitHub
33 changed files with 401 additions and 80 deletions

View File

@ -1400,7 +1400,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.34.0;
MARKETING_VERSION = 1.35.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app;
@ -1435,7 +1435,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.34.0;
MARKETING_VERSION = 1.35.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app;
PRODUCT_NAME = "$(TARGET_NAME)";
@ -1490,7 +1490,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.34.0;
MARKETING_VERSION = 1.35.0;
PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app;
PRODUCT_NAME = Omnivore;
PROVISIONING_PROFILE_SPECIFIER = "";
@ -1831,7 +1831,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.34.0;
MARKETING_VERSION = 1.35.0;
PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app;
PRODUCT_NAME = Omnivore;
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -2,6 +2,35 @@ import Models
import SwiftUI
import Utils
enum FlairLabels: String {
case pinned
case favorite
case recommended
case newsletter
case rss
case feed
var icon: Image {
switch self {
case .pinned: return Image.flairPinned
case .favorite: return Image.flairFavorite
case .recommended: return Image.flairRecommended
case .newsletter: return Image.flairNewsletter
case .feed, .rss: return Image.flairFeed
}
}
var sortOrder: Int {
switch self {
case .feed, .rss: return 0
case .favorite: return 1
case .newsletter: return 2
case .recommended: return 3
case .pinned: return 4
}
}
}
public extension View {
func draggableItem(item: LinkedItem) -> some View {
#if os(iOS)
@ -124,8 +153,30 @@ public struct LibraryItemCard: View {
return ""
}
var flairLabels: [FlairLabels] {
item.sortedLabels.compactMap { label in
if let name = label.name {
return FlairLabels(rawValue: name.lowercased())
}
return nil
}.sorted { $0.sortOrder < $1.sortOrder }
}
var nonFlairLabels: [LinkedItemLabel] {
item.sortedLabels.filter { label in
if let name = label.name, FlairLabels(rawValue: name.lowercased()) != nil {
return false
}
return true
}
}
var readInfo: some View {
AnyView(HStack {
HStack(alignment: .center, spacing: 5.0) {
ForEach(flairLabels, id: \.self) {
$0.icon
}
let fgcolor = Color.isDarkMode ? Color.themeDarkWhiteGray : Color.themeMiddleGray
Text("\(estimatedReadingTime)")
.font(.caption2).fontWeight(.medium)
@ -146,7 +197,7 @@ public struct LibraryItemCard: View {
.font(.caption2).fontWeight(.medium)
.foregroundColor(fgcolor)
}
.frame(maxWidth: .infinity, alignment: .leading))
.frame(maxWidth: .infinity, alignment: .leading)
}
var imageBox: some View {
@ -227,6 +278,6 @@ public struct LibraryItemCard: View {
}
var labels: some View {
LabelsFlowLayout(labels: item.sortedLabels)
LabelsFlowLayout(labels: nonFlairLabels)
}
}

View File

@ -28,4 +28,11 @@ public extension Image {
static var unarchive: Image { Image("unarchive", bundle: .module) }
static var remove: Image { Image("remove", bundle: .module) }
static var label: Image { Image("label", bundle: .module) }
static var flairFeed: Image { Image("flair-feed", bundle: .module) }
static var flairFavorite: Image { Image("flair-favorite", bundle: .module) }
static var flairNewsletter: Image { Image("flair-newsletter", bundle: .module) }
static var flairPinned: Image { Image("flair-pinned", bundle: .module) }
static var flairRecommended: Image { Image("flair-recommended", bundle: .module) }
}

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Frame-2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame-2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame-2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Frame.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Frame-1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame-1 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame-1 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Frame-3.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame-3 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame-3 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Frame-4.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame-4 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame-4 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B