1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
//
// ToolbarWidgetView.swift
// Widget
//
// Created by Marino Faggiana on 25/08/22.
// Copyright © 2022 Marino Faggiana. All rights reserved.
//
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
import SwiftUI
import WidgetKit
struct ToolbarWidgetView: View {
var entry: ToolbarDataEntry
var body: some View {
GeometryReader { geo in
ZStack(alignment: .topLeading) {
Color(.black).opacity(0.9)
.ignoresSafeArea()
HStack(spacing: 0) {
let sizeButton: CGFloat = 65
Link(destination: entry.isPlaceholder ? NCGlobal.shared.widgetActionNoAction : NCGlobal.shared.widgetActionUploadAsset, label: {
Image("addImage")
.resizable()
.renderingMode(.template)
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brandText))
.padding()
.background(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brand))
.clipShape(Circle())
.scaledToFit()
.frame(width: geo.size.width / 4, height: sizeButton)
})
Link(destination: entry.isPlaceholder ? NCGlobal.shared.widgetActionNoAction : NCGlobal.shared.widgetActionScanDocument, label: {
Image("scan")
.resizable()
.renderingMode(.template)
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brandText))
.padding()
.background(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brand))
.clipShape(Circle())
.scaledToFit()
.frame(width: geo.size.width / 4, height: sizeButton)
})
Link(destination: entry.isPlaceholder ? NCGlobal.shared.widgetActionNoAction : NCGlobal.shared.widgetActionTextDocument, label: {
Image("note.text")
.resizable()
.renderingMode(.template)
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brandText))
.padding()
.background(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brand))
.clipShape(Circle())
.scaledToFit()
.frame(width: geo.size.width / 4, height: sizeButton)
})
Link(destination: entry.isPlaceholder ? NCGlobal.shared.widgetActionNoAction : NCGlobal.shared.widgetActionVoiceMemo, label: {
Image("microphone")
.resizable()
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brandText))
.padding()
.background(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brand))
.clipShape(Circle())
.scaledToFit()
.frame(width: geo.size.width / 4, height: sizeButton)
})
}
.frame(width: geo.size.width, height: geo.size.height, alignment: .center)
.redacted(reason: entry.isPlaceholder ? .placeholder : [])
HStack {
Image(systemName: entry.footerImage)
.resizable()
.scaledToFit()
.frame(width: 15, height: 15)
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brand))
Text(entry.footerText)
.font(.caption2)
.padding(.trailing, 13.0)
.foregroundColor(entry.isPlaceholder ? Color(.systemGray4) : Color(NCBrandColor.shared.brand))
}
.frame(maxWidth: geo.size.width - 5, maxHeight: geo.size.height - 2, alignment: .bottomTrailing)
}
}
}
}
struct ToolbarWidget_Previews: PreviewProvider {
static var previews: some View {
let entry = ToolbarDataEntry(date: Date(), isPlaceholder: false, footerImage: "checkmark.icloud", footerText: NCBrandOptions.shared.brand + " toolbar")
ToolbarWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemMedium))
}
}
|