// // NextcloudWidgetView.swift // Widget // // Created by Marino Faggiana on 25/08/22. // Copyright © 2022 Marino Faggiana. All rights reserved. // // Author Marino Faggiana // // 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 . // import SwiftUI import WidgetKit struct NextcloudWidgetView: View { var entry: NextcloudDataEntry var body: some View { ZStack(alignment: .top) { HStack(spacing: 5) { Image("nextcloud") .resizable() .scaledToFit() .frame(width: 10, height: 10) .cornerRadius(3) Text(NCBrandOptions.shared.brand + "k") .font(.system(size: 12)) .textCase(.uppercase) } .padding(.leading, 5) .padding(.bottom, 5) VStack(alignment: .leading, spacing: 5) { VStack(spacing: 5) { ForEach(entry.nextcloudDatas, id: \.id) { element in Link(destination: element.url) { HStack { Image(element.image) .resizable() .aspectRatio(contentMode: .fit) .frame(width: 40, height: 40) .clipShape(Circle()) VStack(alignment: .leading) { Text(element.title) .font(.headline) Text(element.subTitle) .font(.subheadline) .foregroundColor(Color(white: 0.4745)) } Spacer() } .padding(5) } } } }.padding(.top, 5) .redacted(reason: entry.isPlaceholder ? .placeholder : []) Text(entry.footerText) .font(.caption2) .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing) .padding(.trailing, 10.0) .padding(.bottom, 5.0) } } } struct NextcloudWidget_Previews: PreviewProvider { static var previews: some View { let entry = NextcloudDataEntry(date: Date(), nextcloudDatas: nextcloudDatasTest, isPlaceholder: false, footerText: "Nextcloud widget") NextcloudWidgetView(entry: entry).previewContext(WidgetPreviewContext(family: .systemLarge)) } }