ProductView.swift 1.19 KB
Newer Older
 Joel  Oksanen's avatar
Joel Oksanen committed
1 2 3 4 5 6 7 8 9 10 11
//
//  ProductView.swift
//  ADAbot
//
//  Created by Joel Oksanen on 23.2.2020.
//  Copyright © 2020 Joel Oksanen. All rights reserved.
//

import SwiftUI

struct ProductView: View {
12
  @ObservedObject var connectionManager: ConnectionManager
13
  let height: CGFloat = 200
 Joel  Oksanen's avatar
Joel Oksanen committed
14 15 16
  
  var body: some View {
    ZStack {
17 18 19
      Rectangle()
        .foregroundColor(Color.white)
        .frame(height: height)
 Joel  Oksanen's avatar
Joel Oksanen committed
20
        .shadow(color: Color(.sRGB, white: 0, opacity: 0.1), radius: 10, x: 0, y: 0)
21 22 23 24
      
      VStack {
        Spacer()
        HStack(alignment: .top) {
 Joel  Oksanen's avatar
Joel Oksanen committed
25
          VStack(alignment: .leading) {
26 27 28
            Text(connectionManager.product.name)
              .font(Font.custom("Helvetica Neue", size: 14))
              .foregroundColor(Color.gray)
 Joel  Oksanen's avatar
Joel Oksanen committed
29
            RatingView(starRating: connectionManager.product.starRating)
30
          }
31 32 33 34 35 36 37 38 39 40 41
          Spacer()
          Image(uiImage: connectionManager.product.image)
            .resizable()
            .aspectRatio(contentMode: .fit)
            .frame(width: 120, height: 120)
            .border(Color(white: 0.85), width: 1)
        }
        .padding(EdgeInsets(top: 0, leading: 20, bottom: 20, trailing: 20))
      }
      .frame(height: height)
      
 Joel  Oksanen's avatar
Joel Oksanen committed
42 43
    }
  }
 Joel  Oksanen's avatar
Joel Oksanen committed
44
  
 Joel  Oksanen's avatar
Joel Oksanen committed
45
}