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 {
|
|
|
|
|
2020-07-10 01:44:51 +02:00
|
|
|
@EnvironmentObject private var sceneModel: SceneModel
|
2020-07-14 03:18:39 +02:00
|
|
|
@State private var showActivityView = false
|
2020-07-10 01:44:51 +02:00
|
|
|
|
2020-07-06 01:53:18 +02:00
|
|
|
func body(content: Content) -> some View {
|
|
|
|
content
|
|
|
|
.toolbar {
|
|
|
|
#if os(iOS)
|
|
|
|
|
2020-07-23 04:01:02 +02:00
|
|
|
ToolbarItem(placement: .primaryAction) {
|
2020-07-06 01:53:18 +02:00
|
|
|
HStack(spacing: 20) {
|
2020-07-14 00:24:40 +02:00
|
|
|
Button {
|
|
|
|
} label: {
|
2020-07-06 01:53:18 +02:00
|
|
|
AppAssets.prevArticleImage
|
|
|
|
.font(.title3)
|
2020-07-14 00:24:40 +02:00
|
|
|
}
|
|
|
|
.help("Previouse Unread")
|
|
|
|
Button {
|
|
|
|
} label: {
|
|
|
|
AppAssets.nextArticleImage.font(.title3)
|
|
|
|
}
|
|
|
|
.help("Next Unread")
|
2020-07-06 01:53:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-14 00:24:40 +02:00
|
|
|
Button {
|
|
|
|
sceneModel.toggleReadStatusForSelectedArticles()
|
|
|
|
} label: {
|
|
|
|
if sceneModel.readButtonState == true {
|
2020-07-10 01:44:51 +02:00
|
|
|
AppAssets.readClosedImage
|
|
|
|
} else {
|
|
|
|
AppAssets.readOpenImage
|
|
|
|
}
|
2020-07-14 00:24:40 +02:00
|
|
|
}
|
|
|
|
.disabled(sceneModel.readButtonState == nil)
|
|
|
|
.help(sceneModel.readButtonState ?? false ? "Mark as Unread" : "Mark as Read")
|
2020-07-06 01:53:18 +02:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-06 01:53:18 +02:00
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-14 00:24:40 +02:00
|
|
|
Button {
|
|
|
|
sceneModel.toggleStarredStatusForSelectedArticles()
|
|
|
|
} label: {
|
|
|
|
if sceneModel.starButtonState ?? false {
|
2020-07-10 01:44:51 +02:00
|
|
|
AppAssets.starClosedImage
|
|
|
|
} else {
|
|
|
|
AppAssets.starOpenImage
|
|
|
|
}
|
2020-07-14 00:24:40 +02:00
|
|
|
}
|
|
|
|
.disabled(sceneModel.starButtonState == nil)
|
|
|
|
.help(sceneModel.starButtonState ?? false ? "Mark as Unstarred" : "Mark as Starred")
|
2020-07-06 01:53:18 +02:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-06 01:53:18 +02:00
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-14 00:24:40 +02:00
|
|
|
Button {
|
2020-07-19 20:28:22 +02:00
|
|
|
sceneModel.goToNextUnread()
|
2020-07-14 00:24:40 +02:00
|
|
|
} label: {
|
|
|
|
AppAssets.nextUnreadArticleImage.font(.title3)
|
|
|
|
}
|
|
|
|
.disabled(sceneModel.nextUnreadButtonState == nil)
|
|
|
|
.help("Next Unread")
|
2020-07-06 01:53:18 +02:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-06 01:53:18 +02:00
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-14 00:24:40 +02:00
|
|
|
Button {
|
|
|
|
} label: {
|
2020-07-06 01:53:18 +02:00
|
|
|
AppAssets.articleExtractorOff
|
|
|
|
.font(.title3)
|
2020-07-14 00:24:40 +02:00
|
|
|
}
|
|
|
|
.disabled(sceneModel.extractorButtonState == nil)
|
|
|
|
.help("Reader View")
|
2020-07-06 01:53:18 +02:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-06 01:53:18 +02:00
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:57:39 +02:00
|
|
|
ToolbarItem(placement: .bottomBar) {
|
2020-07-14 00:24:40 +02:00
|
|
|
Button {
|
2020-07-14 03:18:39 +02:00
|
|
|
showActivityView.toggle()
|
2020-07-14 00:24:40 +02:00
|
|
|
} 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|