Add Action Buttons to View - Swift UI (Quick $30 bucks)
- or -
Post a project like this1426
$30
- Posted:
- Proposals: 4
- Remote
- #2818539
- Awarded
Description
Experience Level: Entry
I need the section view items in the Scrollview to be buttons that push to other views in the app (index needs to be created on the section items). We may have to convert the view into a NavigationViewController. I will send zip of project. I can't imagine adding actions to these items will take too long. Here is the code of the main view:
import SwiftUI
struct HomeView: View {
@Binding var showProfile: Bool
@State var showUpdate = false
@Binding var showContent: Bool
var body: some View {
ScrollView {
VStack {
HStack(spacing: 12) {
Text("memoryConnect")
.font(.system(size: 28, weight: .bold))
.modifier(CustomFontModifier(size: 28))
Spacer()
AvatarView(showProfile: $showProfile)
Button(action: { self.showUpdate.toggle() }) {
Image(systemName: "bell")
.renderingMode(.original)
.font(.system(size: 16, weight: .medium))
.frame(width: 40, height: 40)
.background(Color.white)
.clipShape(Circle())
.shadow(color: Color.black.opacity(0.1), radius: 1, x: 0, y: 1)
.shadow(color: Color.black.opacity(0.2), radius: 10, x: 0, y: 10)
}
.sheet(isPresented: $showUpdate) {
CourseList()
}
}
.padding(.horizontal)
.padding(.leading, 14)
.padding(.top, 30)
ScrollView(.horizontal, showsIndicators: false) {
WatchRingsView()
.padding(.horizontal, 30)
.padding(.bottom, 30)
.onTapGesture {
self.showContent = true
}
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 20) {
ForEach(sectionData) { item in
GeometryReader { geometry in
SectionView(section: item)
.rotation3DEffect(Angle(degrees:
Double(geometry.frame(in: .global).minX - 30) / -20
), axis: (x: 0, y: 10, z: 0))
}
.frame(width: 275, height: 375)
}
}
.padding(30)
.padding(.bottom, 30)
}
.offset(y: -30)
HStack {
Text("Metrics")
.font(.title).bold()
Spacer()
}
.padding(.leading, 30)
.offset(y: -90)
SectionView(section: sectionData[2], width: screen.width - 60, height: 180)
.offset(y: -85)
Spacer()
}
}
}
}
struct HomeView_Previews: PreviewProvider {
static var previews: some View {
HomeView(showProfile: .constant(false), showContent: .constant(false))
}
}
struct SectionView: View {
var section: Section
var width: CGFloat = 275
var height: CGFloat = 350
var body: some View {
VStack {
HStack(alignment: .top) {
Text(section.title)
.font(.system(size: 24, weight: .medium))
.frame(width: 190, alignment: .leading)
.foregroundColor(.white)
Spacer()
Image(section.logo)
}
Text(section.text.uppercased())
.frame(maxWidth: .infinity, alignment: .leading)
section.image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 210)
}
.padding(.top, -30)
.padding(.horizontal, 20)
.frame(width: width, height: height)
.background(section.color)
.cornerRadius(30)
.shadow(color: section.color.opacity(0.3), radius: 20, x: 0, y: 20)
}
}
import SwiftUI
struct HomeView: View {
@Binding var showProfile: Bool
@State var showUpdate = false
@Binding var showContent: Bool
var body: some View {
ScrollView {
VStack {
HStack(spacing: 12) {
Text("memoryConnect")
.font(.system(size: 28, weight: .bold))
.modifier(CustomFontModifier(size: 28))
Spacer()
AvatarView(showProfile: $showProfile)
Button(action: { self.showUpdate.toggle() }) {
Image(systemName: "bell")
.renderingMode(.original)
.font(.system(size: 16, weight: .medium))
.frame(width: 40, height: 40)
.background(Color.white)
.clipShape(Circle())
.shadow(color: Color.black.opacity(0.1), radius: 1, x: 0, y: 1)
.shadow(color: Color.black.opacity(0.2), radius: 10, x: 0, y: 10)
}
.sheet(isPresented: $showUpdate) {
CourseList()
}
}
.padding(.horizontal)
.padding(.leading, 14)
.padding(.top, 30)
ScrollView(.horizontal, showsIndicators: false) {
WatchRingsView()
.padding(.horizontal, 30)
.padding(.bottom, 30)
.onTapGesture {
self.showContent = true
}
}
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 20) {
ForEach(sectionData) { item in
GeometryReader { geometry in
SectionView(section: item)
.rotation3DEffect(Angle(degrees:
Double(geometry.frame(in: .global).minX - 30) / -20
), axis: (x: 0, y: 10, z: 0))
}
.frame(width: 275, height: 375)
}
}
.padding(30)
.padding(.bottom, 30)
}
.offset(y: -30)
HStack {
Text("Metrics")
.font(.title).bold()
Spacer()
}
.padding(.leading, 30)
.offset(y: -90)
SectionView(section: sectionData[2], width: screen.width - 60, height: 180)
.offset(y: -85)
Spacer()
}
}
}
}
struct HomeView_Previews: PreviewProvider {
static var previews: some View {
HomeView(showProfile: .constant(false), showContent: .constant(false))
}
}
struct SectionView: View {
var section: Section
var width: CGFloat = 275
var height: CGFloat = 350
var body: some View {
VStack {
HStack(alignment: .top) {
Text(section.title)
.font(.system(size: 24, weight: .medium))
.frame(width: 190, alignment: .leading)
.foregroundColor(.white)
Spacer()
Image(section.logo)
}
Text(section.text.uppercased())
.frame(maxWidth: .infinity, alignment: .leading)
section.image
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 210)
}
.padding(.top, -30)
.padding(.horizontal, 20)
.frame(width: width, height: height)
.background(section.color)
.cornerRadius(30)
.shadow(color: section.color.opacity(0.3), radius: 20, x: 0, y: 20)
}
}
Bradley D.
100% (14)Projects Completed
6
Freelancers worked with
6
Projects awarded
63%
Last project
12 May 2021
United States
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies