txtodo

[DORMANT] a minimalist todo list app inspired by jeff huang
git clone git://git.figbert.com/txtodo.git
Log | Files | Refs | README

DonationSection.swift (1446B)


      1 //
      2 //  DonationSection.swift
      3 //  txtodo
      4 //
      5 //  Created by FIGBERT on 11/16/20.
      6 //
      7 
      8 import SwiftUI
      9 
     10 struct DonationSection: View {
     11     @StateObject var storeManager: StoreManager
     12     @Environment(\.colorScheme) var colorScheme
     13     
     14     var body: some View {
     15         VStack {
     16             Text("considerDonating")
     17                 .multilineTextAlignment(.center)
     18                 .padding()
     19             HStack {
     20                 if storeManager.myProducts.isEmpty {
     21                     ProgressView()
     22                         .progressViewStyle(CircularProgressViewStyle())
     23                 } else {
     24                     ForEach(storeManager.myProducts.sorted(by: { first, second in return first.price.doubleValue < second.price.doubleValue }), id: \.self) { product in
     25                         Text(product.priceFormatted())
     26                             .foregroundColor(Color.white)
     27                             .padding()
     28                             .background(Color.blue.opacity(self.colorScheme == .dark ? 0.3 : 0.75).cornerRadius(10))
     29                             .onTapGesture {
     30                                 self.storeManager.purchaseProduct(product: product)
     31                             }
     32                     }
     33                 }
     34             }
     35                 .padding(.bottom)
     36         }
     37     }
     38 }
     39 
     40 struct DonationSection_Previews: PreviewProvider {
     41     static var previews: some View {
     42         DonationSection(storeManager: StoreManager())
     43     }
     44 }