NetNewsWire/Multiplatform/Shared/Article/ArticleToolbarModifier.swift

120 lines
2.7 KiB
Swift
Raw Normal View History

2020-07-06 01:53:18 +02:00
//
// ArticleToolbarModifier.swift
// NetNewsWire
//
// Created by Maurice Parker on 7/5/20.
// Copyright © 2020 Ranchero Software. All rights reserved.
//
import SwiftUI
struct ArticleToolbarModifier: ViewModifier {
@EnvironmentObject private var sceneModel: SceneModel
2020-07-14 03:18:39 +02:00
@State private var showActivityView = false
2020-07-06 01:53:18 +02:00
func body(content: Content) -> some View {
content
.toolbar {
#if os(iOS)
ToolbarItem(placement: .navigation) {
HStack(spacing: 20) {
Button {
} label: {
2020-07-06 01:53:18 +02:00
AppAssets.prevArticleImage
.font(.title3)
}
.help("Previouse Unread")
Button {
} label: {
AppAssets.nextArticleImage.font(.title3)
}
.help("Next Unread")
2020-07-06 01:53:18 +02:00
}
}
ToolbarItem(placement: .bottomBar) {
Button {
sceneModel.toggleReadStatusForSelectedArticles()
} label: {
if sceneModel.readButtonState == true {
AppAssets.readClosedImage
} else {
AppAssets.readOpenImage
}
}
.disabled(sceneModel.readButtonState == nil)
.help(sceneModel.readButtonState ?? false ? "Mark as Unread" : "Mark as Read")
2020-07-06 01:53:18 +02:00
}
ToolbarItem(placement: .bottomBar) {
2020-07-06 01:53:18 +02:00
Spacer()
}
ToolbarItem(placement: .bottomBar) {
Button {
sceneModel.toggleStarredStatusForSelectedArticles()
} label: {
if sceneModel.starButtonState ?? false {
AppAssets.starClosedImage
} else {
AppAssets.starOpenImage
}
}
.disabled(sceneModel.starButtonState == nil)
.help(sceneModel.starButtonState ?? false ? "Mark as Unstarred" : "Mark as Starred")
2020-07-06 01:53:18 +02:00
}
ToolbarItem(placement: .bottomBar) {
2020-07-06 01:53:18 +02:00
Spacer()
}
ToolbarItem(placement: .bottomBar) {
Button {
} label: {
AppAssets.nextUnreadArticleImage.font(.title3)
}
.disabled(sceneModel.nextUnreadButtonState == nil)
.help("Next Unread")
2020-07-06 01:53:18 +02:00
}
ToolbarItem(placement: .bottomBar) {
2020-07-06 01:53:18 +02:00
Spacer()
}
ToolbarItem(placement: .bottomBar) {
Button {
} label: {
2020-07-06 01:53:18 +02:00
AppAssets.articleExtractorOff
.font(.title3)
}
.disabled(sceneModel.extractorButtonState == nil)
.help("Reader View")
2020-07-06 01:53:18 +02:00
}
ToolbarItem(placement: .bottomBar) {
2020-07-06 01:53:18 +02:00
Spacer()
}
ToolbarItem(placement: .bottomBar) {
Button {
2020-07-14 03:18:39 +02:00
showActivityView.toggle()
} label: {
AppAssets.shareImage.font(.title3)
}
.disabled(sceneModel.shareButtonState == nil)
.help("Share")
2020-07-14 03:18:39 +02:00
.sheet(isPresented: $showActivityView) {
if let article = sceneModel.selectedArticles.first, let link = article.preferredLink, let url = URL(string: link) {
ActivityViewController(title: article.title, url: url)
}
}
2020-07-06 01:53:18 +02:00
}
#endif
}
}
}