ContentView.swift
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | // // ContentView.swift // SwiftUIProject // // Created by Cairocoders // import SwiftUI struct ContentView: View { @State var data: userlist? var body: some View { NavigationView { VStack { HStack(spacing: 16) { Image( "pic" ) .resizable() .scaledToFill() .frame(width: 50, height: 50) .clipped() .cornerRadius(50) .overlay(RoundedRectangle(cornerRadius: 44) .stroke(Color(.label), lineWidth: 1) ) .shadow(radius: 5) VStack(alignment: .leading, spacing: 4) { Text( "cairocoders" ) .font(. system (size: 24, weight: .bold)) HStack { Circle() .foregroundColor(.green) .frame(width: 14, height: 14) Text( "online" ) .font(. system (size: 12)) .foregroundColor(Color(.lightGray)) } } Spacer() Button { } label: { Image(systemName: "gear" ) .font(. system (size: 24, weight: .bold)) .foregroundColor(Color(.label)) } } //End HStack .padding() ScrollView { ForEach(user){i in Button(action: { data = .init(id: i.id, name: i.name, image: i.image, pic: i.pic) }) { VStack { HStack(spacing: 16) { Image(i.image) .resizable() .scaledToFill() .frame(width: 50, height: 50) .clipped() .cornerRadius(50) VStack(alignment: .leading) { Text(i.name) .font(. system (size: 16, weight: .bold)) Text( "View Profile" ) .font(. system (size: 14)) .foregroundColor(Color(.lightGray)) } Spacer() Text( "22m" ) .font(. system (size: 14, weight: .semibold)) } Divider() .padding(.vertical, 8) }.padding(.horizontal) } } //End ForEach .padding(.bottom, 50) .sheet(item: $data) { rs in Profile(viewdata: rs) } } // End scrollview } .navigationBarHidden( true ) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct userlist : Identifiable { var id : Int var name : String var image : String var pic : String } var user = [ userlist(id: 0, name: "Taylor" , image: "photo1" , pic: "1" ), userlist(id: 1, name: "Mari" , image: "photo2" , pic: "2" ), userlist(id: 2, name: "Sandra" , image: "photo3" , pic: "3" ) ] |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | // // Profile.swift // SwiftUIProject // // Created by Cairocoders // import SwiftUI struct Profile : View { @Environment(\.presentationMode) var presentationMode let viewdata : userlist var body : some View{ ZStack{ Image(viewdata.pic).resizable().edgesIgnoringSafeArea(.all) VStack{ HStack{ Button(action: { }) { Image(systemName: "slider.horizontal.3" ).foregroundColor(Color.black).font(.title) } Spacer() Button(action: { presentationMode.wrappedValue.dismiss() }) { Image(systemName: "xmark" ).foregroundColor(Color.black).font(.title) } } Spacer() ZStack(alignment: .top) { VStack{ HStack{ VStack(alignment: .leading, spacing: 10) { Text( "\(viewdata.name)," ).font(.title) Text( "19" ) } Spacer() HStack(spacing: 8){ Image(systemName: "mappin.and.ellipse" ) Text( "2 Miles" ) }.padding(8) .background(Color.black.opacity(0.1)) .cornerRadius(10) }.padding(.top,35) Text( "Hi! My name \(viewdata.name). I like sharing my thoughts and adore people who except me the way I am. Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit. Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit." ).padding(.top) }.padding() .background(Blurview()) .clipShape(BottomShape()) .cornerRadius(25) ZStack{ Button(action: { }) { Image(systemName: "message.and.waveform" ) .frame(width: 20, height: 20) .padding(20) .background(Color.white) .clipShape(Circle()) .font(.title) .foregroundColor(Color.green) } Circle().stroke(Color.green, lineWidth: 5).frame(width: 70, height: 70) }.offset(y: -35) HStack{ Button(action: { }) { Image(systemName: "suit.heart" ) .frame(width: 25, height: 20) .padding() .background(Color.white) .clipShape(Circle()) .font(.title) .foregroundColor(Color.red) } Spacer() Button(action: { }) { Image(systemName: "hand.thumbsup" ) .frame(width: 25, height: 25) .padding() .background(Color.white) .clipShape(Circle()) .font(.title) .foregroundColor(Color.blue) } }.offset(y: -25) .padding(.horizontal,35) } }.padding() } } } struct BottomShape : Shape { func path(in rect: CGRect) -> Path { return Path{path in path.move(to: CGPoint(x: 0, y: 0)) path.addLine(to: CGPoint(x: 0, y: rect.height)) path.addLine(to: CGPoint(x: rect.width, y: rect.height)) path.addLine(to: CGPoint(x: rect.width, y: 0)) path.addArc(center: CGPoint(x: rect.width / 2, y: 0), radius: 42, startAngle: .zero, endAngle: .init(degrees: 180), clockwise: false ) } } } struct Blurview : UIViewRepresentable { func makeUIView(context: UIViewRepresentableContext<Blurview>) -> UIVisualEffectView { let view = UIVisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterialLight)) return view } func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext<Blurview>) { } } struct Profile_Previews: PreviewProvider { static var previews: some View { Profile(viewdata: userlist(id: 1, name: "Taylor" , image: "photo1" , pic: "1" )) } } |