Vasilis

fixes in couponsview

......@@ -92,6 +92,15 @@ struct ImageView: View {
}
}
struct VLine: Shape {
func path(in rect: CGRect) -> Path {
Path { path in
path.move(to: CGPoint(x: rect.midX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY))
}
}
}
extension CouponsView {
struct headerView: View {
var goBack: () -> ()
......@@ -104,13 +113,14 @@ extension CouponsView {
HStack {
Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
.offset(y: self.uiscreen.height * 0.018)
.frame(width: self.uiscreen.height * 0.022, height: self.uiscreen.height * 0.02)
.offset(y: self.uiscreen.height * 0.015)
}
}
Text("Όλα τα κουπόνια μου")
.frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
.offset( y: self.uiscreen.height * 0.02)
.font(.system(size: 15))
}
.frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.1)
}
......@@ -126,15 +136,31 @@ extension CouponsView {
return "\(parameter)"
}
static func convertDateFormat(inputDate: String) -> String {
let olDateFormatter = DateFormatter()
olDateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
let oldDate = olDateFormatter.date(from: inputDate)
let convertDateFormatter = DateFormatter()
convertDateFormatter.dateFormat = "dd/MM/yyyy"
return convertDateFormatter.string(from: oldDate!)
}
var body: some View {
VStack(alignment: .leading) {
HStack(alignment: .center) {
ImageView(withURL: result["img_preview"] as! String)
.frame(maxWidth: self.uiscreen.width * 0.15)
.padding(.leading , self.uiscreen.width * 0.04)
Rectangle()
.frame(width: 1, height: self.uiscreen.height * 0.1 * 0.93)
VLine()
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5]))
.foregroundColor(Color(red: 0.4392156862745098, green: 0.4392156862745098, blue: 0.4392156862745098))
.frame(width: 1)
.padding(.leading, self.uiscreen.width * 0.01)
Spacer()
VStack {
Text(CouponsView.couponView.localizedWithParameter(parameter: result["admin_name"] as? String ?? ""))
......@@ -143,7 +169,7 @@ extension CouponsView {
Text(CouponsView.couponView.localizedWithParameter(parameter: result["discount"] as? String ?? ""))
.frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: self.uiscreen.height * 0.05, alignment: .leading)
.font(.system(size: 47))
Text(CouponsView.couponView.localizedWithParameter(parameter: "Ισχύει εώς " + (result["expiration"] as? String ?? "").components(separatedBy: [" "]).filter({!$0.isEmpty})[0]))
Text(CouponsView.couponView.localizedWithParameter(parameter: "Ισχύει εώς " + CouponsView.couponView.convertDateFormat(inputDate: result["expiration"] as? String ?? "")))
.frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading)
.font(.system(size: 10))
}
......@@ -164,7 +190,7 @@ extension CouponsView {
Image("coupons_container", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
)
.padding(.top, self.uiscreen.height * 0.05)
.padding(.bottom, self.uiscreen.height * 0.04)
}
}
......@@ -198,6 +224,7 @@ struct CouponsView: View {
couponView(result: result, index: index) }
}
}
.padding(.top, self.uiscreen.height * 0.05)
}
.frame(width:self.uiscreen.width, height:self.uiscreen.height * 0.9 )
.background(
......