Untitled
unknown
plain_text
a year ago
21 kB
19
Indexable
//
// Shop.swift
// TrainerApp
//
// Created by ISDT Devs on 22.10.24.
//
import SwiftUI
//import FirebaseFirestoreSwift
import FirebaseAuth
import FirebaseStorage
struct Shop: View {
let currentBalance = "$30,000"
@State private var navigateToProductList: Bool = false
@State private var navigateToManageProduct: Bool = false
@Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView{
VStack{
ScrollView(.vertical, showsIndicators: false) {
VStack {
Button(action: {
navigateToManageProduct = true
}) {
Text("Add New Product")
.foregroundColor(.white)
.multilineTextAlignment(.center)
.frame(height: 38)
.frame(maxWidth:.infinity)
.font(.plusJakartaSans(size: 14, weight: .semibold))
.background(Color(red: 0.13, green: 0.77, blue: 0.37))
.cornerRadius(100)
.padding(.top,30)
}
.padding(.vertical,10)
NavigationLink(destination: ManageProductSegment(), isActive: $navigateToManageProduct) {
EmptyView()
}
//.padding(.horizontal, 20)
HStack {
NavigationLink(destination: ProductListView()) {
Image("packing")
.resizable()
.scaledToFit()
.frame(width: 74, height: 74)
.padding(.leading, 10)
VStack(alignment: .leading, spacing: 4) {
Text("20")
.font(.plusJakartaSans(size: 30, weight: .bold))
.foregroundColor(.white)
Text("Total Product")
.font(.plusJakartaSans(size: 16, weight: .semibold))
.foregroundColor(.white)
}
.padding(.leading, 10)
Spacer() // Push everyth
}
}
.cornerRadius(10) // Rounded corne
.frame(height:100)
.background(Color(red: 0.2, green: 0.81, blue: 1))
.padding(.top,5)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray, lineWidth: 0)
.padding(.top,10)
)
// .padding(.horizontal, 20)
NavigationLink(destination: TotalOrder()){
HStack {
Image("knitting")
.resizable()
.scaledToFit()
.frame(width: 74, height: 74)
.padding(.leading, 10)
VStack(alignment: .leading, spacing: 4) { // VStack for vertical alignment
Text("20")
.font(.plusJakartaSans(size: 30, weight: .bold))
.foregroundColor(.white) // First text field
Text("Total Order")
.font(.plusJakartaSans(size: 16, weight: .semibold))
.foregroundColor(.white)
}
.padding(.leading, 10)
Spacer() // Push everyth
}
}
.cornerRadius(10) // Rounded corne
.frame(height:100)
.background(Color(red: 0.25, green: 0.77, blue: 0.67))
.padding(.top,5)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray, lineWidth: 0)
.padding(.top,10)
)
// .padding(.horizontal, 20)
NavigationLink(destination: TotalOrder()){
HStack {
Image("knitting")
.resizable()
.scaledToFit()
.frame(width: 74, height: 74)
.padding(.leading, 10)
VStack(alignment: .leading, spacing: 4) {
Text("5")
.font(.plusJakartaSans(size: 30, weight: .bold))
.foregroundColor(.white)
Text("Pending Order")
.font(.plusJakartaSans(size: 16, weight: .semibold))
.foregroundColor(.white)
}
.padding(.leading, 10)
Spacer() // Push everyth
}
}
.cornerRadius(10) // Rounded corne
.frame(height:100)
.background(Color(red: 1, green: 0.75, blue: 0.3))
.padding(.top,5)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.gray, lineWidth: 0)
.padding(.top,10)
)
// .padding(.horizontal, 20)
HStack{
Divider()
.frame(height: 1)
.frame(maxWidth: .infinity)
.background(Color(hex: "#DFE1E7")) // Optional: Set the line color
// .padding()
}
// .padding(.horizontal,20)
.padding(.vertical,20)
HStack(spacing: 10) {
VStack(spacing:10) {
Text("Shop Setting")
// .padding(.top, 5)
.font(.plusJakartaSans(size: 16, weight: .bold))
Text("Manage & organise\nyour shop")
.font(.plusJakartaSans(size: 12, weight: .regular))
.foregroundColor(Color(hex: "#0F172A"))
.multilineTextAlignment(.center)
.lineLimit(nil)
.frame(maxWidth: .infinity)
Image("Home 1")
NavigationLink(destination: ShopInfoView()) { // Navigate to the SettingsView
Text("Go to setting")
.foregroundColor(.white)
.font(.plusJakartaSans(size: 12, weight: .semibold))
.frame(height:30)
//.frame(maxWidth:160)
.frame(maxWidth: .infinity)
.background(Color(red: 0.13, green: 0.77, blue: 0.37))
.cornerRadius(5)
}
.padding(.horizontal,15)
}
.frame(height: calculateHeight())
.background(Color(red: 0.91, green: 0.98, blue: 0.94))
.cornerRadius(10)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color(hex: "#DFE1E7"), lineWidth: 1)
)
// Second box (same as first one)
VStack(spacing:10) {
Text("Payment Setting")
//.padding(.top, 5)
.font(.plusJakartaSans(size: 16, weight: .bold))
Text("Configure your payment\nmethod")
// .padding(.bottom, 10)
.foregroundColor(Color(hex: "#0F172A"))
.font(.plusJakartaSans(size: 12, weight: .regular))
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity)
// Image(uiImage: UIImage(named: "Home 1")!)
Image("Card_PaymentSetting")
NavigationLink(destination: ReelsView(), isActive: $navigateToProductList) {
EmptyView()
}
Button(action: {
navigateToProductList = true
})
{
Text("Configure Now")
.foregroundColor(.white)
.font(.plusJakartaSans(size: 12, weight: .semibold))
.frame(height:30)
.frame(maxWidth: .infinity)
.background(Color(red: 0.13, green: 0.77, blue: 0.37))
.cornerRadius(5)
}
.padding(.horizontal,15)
//Spacer()
}
//.frame(height: 157)
.frame(height: calculateHeight())
.frame(maxWidth: .infinity)
.background(Color(red: 0.91, green: 0.98, blue: 0.94))
.cornerRadius(10)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color(hex: "#DFE1E7"), lineWidth: 1)
)
}
/// .padding()
// .padding(.horizontal,20)
VStack{
SalesStatsChart()
.background(Color(hex: "#f6f8fa"))
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color(hex: "#DFE1E7"), lineWidth:1)
)
.frame(width: calculateWidth(), height: calculateHeight())
}
.padding(.top,40)
}
}
}
// .onAppear {
// guard let id = Auth.auth().currentUser?.uid else {
// print("User ID not found")
// return
// }
// viewModels.fetchBook(documentId: id)
// print("This is View Model Data",viewModels)
// }
.padding(.horizontal,20)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
HStack (spacing: 8){
Image("Variant=18")
.resizable()
.frame(width: 40, height: 40)
.clipShape(Circle())
.overlay(
Circle()
.stroke(Color.green, lineWidth: 1)
.frame(width: 40, height: 40)
)
Text("My Shop")
.font(Font.plusJakartaSans(size: 17).weight(.bold))
}
}
ToolbarItem(placement: .navigationBarTrailing){
VStack(spacing: 10) {
VStack {
Text("Current Balance")
.font(Font.plusJakartaSans(size: 11).weight(.bold))
.foregroundColor(Color(hex: "#A4ACB9"))
Text(currentBalance)
.font(Font.plusJakartaSans(size: 15).weight(.bold))
.foregroundColor(Color(hex: "#0F172A"))
.multilineTextAlignment(.trailing)
}
}
}
}
.navigationBarTitleDisplayMode(.inline)
}
}
private func calculateWidth() -> CGFloat {
let screenWidth = UIScreen.main.bounds.width
return screenWidth / 1.1 // Adjust the divisor to fit your layout needs
}
private func calculateHeight() -> CGFloat {
let screenHeight = UIScreen.main.bounds.height
return screenHeight / 5 // Adjust the divisor to fit your layout needs
}
}
struct Shop_Previewse: PreviewProvider {
static var previews: some View {
Shop()
}
}
struct SalesStatsChart: View {
let days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
let calories: [CGFloat] = [20, 40, 80, 120, 60, 70, 50]
let weeks = ["Week 1", "Week 2", "Week 3", "Week 4"]
let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
@State var selectedWeek: String = "Week"
let weekList = ["Week", "Day", "Month"]
var body: some View {
VStack {
HStack {
Image(systemName: "flame.fill")
.foregroundColor(.green)
.padding(.vertical,15)
///.padding(.horizontal,10)
Text("Sales Stats")
.font(.system(size: 16, weight: .semibold))
Spacer()
Menu {
ForEach(weekList, id: \.self) { option in
Button(action: {
self.selectedWeek = option
}) {
Text(option)
}
}
}
label: {
HStack {
Text(self.selectedWeek)
.foregroundColor(Color(hex: "#818898"))
.foregroundColor(self.selectedWeek.isEmpty ? .gray : .black)
Image(systemName: "chevron.down")
.foregroundColor(.gray)
}
}
}
.padding(.horizontal,20)
//.padding(.horizontal,20)
//Spacer()
// Conditionally render the chart based on the selection
if selectedWeek == "Week" {
weekChart
} else if selectedWeek == "Day" {
dayChart
} else if selectedWeek == "Month" {
monthChart
}
// Spacer()
}
//.padding(.horizontal,10)
.padding(.bottom,10)
}
var weekChart: some View {
HStack(alignment: .bottom, spacing: 10) {
ForEach(0..<days.count, id: \.self) { index in
VStack {
Rectangle()
.fill(index == 2 ? Color.green : Color.gray.opacity(0.2)) // Example: Highlight Tuesday
.cornerRadius(5)
.frame(width: 35, height: calories[index])
Text(days[index])
.font(.system(size: 12))
.foregroundColor(.gray)
}
}
}
.padding(.horizontal)
}
var dayChart: some View {
HStack(alignment: .bottom, spacing: 10) {
ForEach(0..<weeks.count, id: \.self) { index in
VStack {
Rectangle()
.fill(index == 2 ? Color.green : Color.gray.opacity(0.2)) // Example: Highlight Tuesday
.cornerRadius(5)
.frame(width: 35, height: calories[index])
Text(weeks[index])
.font(.system(size: 12))
.foregroundColor(.gray)
}
}
}
.padding(.horizontal)
}
var monthChart: some View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(alignment: .bottom, spacing: 10) {
ForEach(0..<months.count, id: \.self) { index in
VStack {
Rectangle()
.fill(Color.gray.opacity(0.2))
.cornerRadius(5)
.frame(height: CGFloat.random(in: 50...150)) // Example heights
.frame(maxWidth: .infinity)
Text(months[index])
.font(.system(size: 12))
.foregroundColor(.gray)
}
}
}
// .padding(.horizontal,20)
}
}
}
//func fetchBook(documentId: String) {
//
// let query = db.collection("Products")
// query.getDocuments { [weak self] (snapshot, error) in
// if let error = error {
// print("Error fetching groups: \(error.localizedDescription)")
// return
// }
//
// guard let documents = snapshot?.documents else {
//
// print("No groups found")
// return
// }
//
// documents.compactMap { document in
// let data = document.data()
// print("Data",data)
//
//
//
// }
//
//
//
//
//
//
// }
//
//
//}
Editor is loading...
Leave a Comment