Vasilis

wallet not ready

......@@ -390,7 +390,7 @@ extension GiftsView {
// addChild(couponsViewController)
campaignViewController.view.frame = parentView.frame
parentView.addSubview(campaignViewController.view)
campaignViewController.didMove(toParent: UIHostingController(rootView: self))
// campaignViewController.didMove(toParent: UIHostingController(rootView: self))
} label: {
HStack(alignment: .center) {
......@@ -506,7 +506,7 @@ extension GiftsView {
// addChild(couponsViewController)
couponViewController.view.frame = parentView.frame
parentView.addSubview(couponViewController.view)
couponViewController.didMove(toParent: UIHostingController(rootView: self))
// couponViewController.didMove(toParent: UIHostingController(rootView: self))
} label: {
HStack(alignment: .center) {
......
......@@ -92,11 +92,17 @@ extension MoreForYouView {
HStack {
VStack(alignment: .leading) {
Text(MoreForYouView.inboxView.localizedWithParameter(parameter: result["title"] as? String ?? ""))
.font(.system(size: 17).italic())
.fontWeight(.bold)
.foregroundColor(Color(hex: 0x3A5266))
.frame(maxWidth: self.uiscreen.width * 0.65, alignment: .topLeading)
.padding(.top, self.uiscreen.height * 0.01)
.padding(.leading, self.uiscreen.width * 0.03)
Spacer()
Text(MoreForYouView.inboxView.localizedWithParameter(parameter: result["subtitle"] as? String ?? ""))
.font(.system(size: 16))
.fontWeight(.medium)
.foregroundColor(Color(hex: 0x415564))
.frame(maxWidth: self.uiscreen.width * 0.72, alignment: .topLeading)
.padding(.leading, self.uiscreen.width * 0.03)
.padding(.bottom, self.uiscreen.height * 0.01)
......@@ -166,6 +172,7 @@ struct MoreForYouView: View {
.background(
LinearGradient(gradient: Gradient(colors: [Color(hex: 0x1AADCC), Color(hex: 0x83C062)]), startPoint: .top, endPoint: .bottom)
)
.cornerRadius(20, corners: [.topLeft])
}
.frame(width:self.uiscreen.width, height:self.uiscreen.height )
......
......@@ -7,7 +7,32 @@
import SwiftUI
class ProfileDataModel {
var data: NSDictionary
init() { //initializer method
let instanceOfMyApi = MyApi()
let profile = instanceOfMyApi.getProfile()
var profileData = NSDictionary()
if let profileDictionary = profile as? [String : AnyObject] {
profileData = (profileDictionary["result"] as! NSDictionary)
}
self.data = profileData
}
var getData: NSDictionary {
get { // getter
return data
}
}
}
extension WalletView {
static func localizedWithParameter(parameter: String) -> LocalizedStringKey {
return "\(parameter)"
}
struct headerView: View {
var goBack: () -> ()
var uiscreen = UIScreen.main.bounds
......@@ -31,6 +56,89 @@ extension WalletView {
.frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.1)
}
}
struct ImageView: View {
@ObservedObject var imageLoader:UrlImageModel
@State var width:CGFloat
@State var height:CGFloat
@State var isFill:Bool
var uiscreen = UIScreen.main.bounds
init(withURL url:String , width:CGFloat, height: CGFloat, isFill:Bool) {
imageLoader = UrlImageModel(urlString:url)
self.width = width
self.height = height
self.isFill = isFill
}
var body: some View {
Image(uiImage: imageLoader.image ?? UIImage())
.resizable()
.frame(minWidth: self.uiscreen.width * 0.95, idealWidth: self.uiscreen.width * 0.95, maxWidth: self.uiscreen.width * 0.95, minHeight: self.uiscreen.height * 0.2, idealHeight: self.uiscreen.height * 0.2, maxHeight: self.uiscreen.height * 0.2, alignment: .leading)
.scaledToFill()
.aspectRatio(contentMode: isFill ? .fill : .fit)
.cornerRadius(4)
}
}
struct myCoupons: View {
var uiscreen = UIScreen.main.bounds
var body: some View {
HStack {
}
.frame(width: self.uiscreen.width)
}
}
struct linearView: View {
var data: NSDictionary
var uiscreen = UIScreen.main.bounds
var body: some View {
VStack{
HStack {
VStack(alignment: .leading) {
Text("Ενεργός κωδικός:")
.font(.system(size: 17))
.fontWeight(.medium)
.foregroundColor(Color(hex: 0x3C5365))
Text("961544809")
.font(.system(size: 17))
.fontWeight(.bold)
.foregroundColor(Color(hex: 0x3C5365))
Text("Λήγει σε 4 ημέρες")
.font(.system(size: 11))
.fontWeight(.medium)
.foregroundColor(Color(hex: 0x84929E))
}
Spacer()
Image("deals_for_you")
.resizable()
.frame(width: self.uiscreen.height * 0.08, height: self.uiscreen.height * 0.08)
.padding(.top, self.uiscreen.height * 0.01)
.padding(.bottom, self.uiscreen.height * 0.01)
}
.padding(.leading, self.uiscreen.width * 0.04)
.padding(.trailing, self.uiscreen.width * 0.04)
.frame(width: self.uiscreen.width * 0.95, alignment: .leading)
.background(Color.white)
.cornerRadius(3)
.padding(.top, self.uiscreen.height * 0.04)
.padding(.bottom, self.uiscreen.height * 0.04)
myCoupons()
}
.frame(width: self.uiscreen.width, alignment: .center)
.background(
LinearGradient(gradient: Gradient(colors: [Color(hex: 0x1AADCC), Color(hex: 0x83C062)]), startPoint: .top, endPoint: .bottom)
)
.cornerRadius(15, corners: [.topLeft])
}
}
}
struct WalletView: View {
......@@ -38,6 +146,8 @@ struct WalletView: View {
var uiscreen = UIScreen.main.bounds
var data: NSDictionary = ProfileDataModel().getData
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 3) {
......@@ -50,14 +160,64 @@ struct WalletView: View {
VStack {
headerView(goBack: goBack)
ScrollView(showsIndicators: false) {
HStack {
ZStack {
if let value = (data["result"] as? String) {
ImageView(withURL: value, width: self.uiscreen.height * 0.05, height: self.uiscreen.height * 0.05, isFill: true)
.cornerRadius(self.uiscreen.height * 0.05)
.padding(.leading, self.uiscreen.width * 0.05)
} else {
Image("generic_profile")
.frame(width: self.uiscreen.height * 0.05, height: self.uiscreen.height * 0.05)
.background(Color.black)
.cornerRadius(self.uiscreen.height * 0.05)
.padding(.leading, self.uiscreen.width * 0.05)
}
Circle()
.strokeBorder(Color(hex: 0x22A9B5), lineWidth: 1)
.frame(width: self.uiscreen.height * 0.05, height: self.uiscreen.height * 0.05)
.padding(.leading, self.uiscreen.width * 0.05)
}
VStack(alignment: .leading) {
Text(WalletView.localizedWithParameter(parameter: data["firstname"] as! String + " " + (data["lastname"] as! String)))
.font(.system(size: 13))
.padding(.top, self.uiscreen.height * 0.005)
.frame(width: self.uiscreen.width * 0.7, alignment: .leading)
Spacer()
if let value = (data["profile_metadata"] as? NSDictionary) {
if ((value["answered"] != nil) == true) {
VStack {
}
.frame(width:self.uiscreen.width, height:self.uiscreen.height * 0.9 )
.background(
LinearGradient(gradient: Gradient(colors: [Color(hex: 0x1AADCC), Color(hex: 0x83C062)]), startPoint: .top, endPoint: .bottom)
LinearGradient(gradient: Gradient(colors: [Color(hex: 0x1AADCC), Color(hex: 0x83C062)]), startPoint: .trailing, endPoint: .leading)
)
}
} else {
HStack {
Text("+")
.font(.system(size: 17))
.padding(.bottom, 2)
Text("Ερωτηματολόγιο")
.font(.system(size: 13))
.fontWeight(.medium)
}
.padding(.leading, 5)
.padding(.trailing, 5)
.overlay(
RoundedRectangle(cornerRadius: 16).stroke(Color(hex: 0x556778), lineWidth: 1)
)
.padding(.bottom, self.uiscreen.height * 0.005)
}
}
.padding(.leading , self.uiscreen.width * 0.025)
}
.frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.06, alignment: .leading)
linearView(data: data)
}
.frame(width:self.uiscreen.width, height:self.uiscreen.height * 0.9 )
}
.frame(width:self.uiscreen.width, height:self.uiscreen.height )
}
}
......