Skip to content

Commit

Permalink
base 010
Browse files Browse the repository at this point in the history
  • Loading branch information
jopolaz committed Jan 6, 2021
1 parent 861c47b commit fd06e2f
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
@@ -1,2 +1,3 @@
# YLOnBoarding

Documentation coming ...
32 changes: 30 additions & 2 deletions Sources/YLOnBoarding/YLOnBoarding.swift
Expand Up @@ -8,13 +8,41 @@
import SwiftUI

struct YLOnBoarding: View {

let title: String
let style: YLOnBoardingStyle
let items: [YLOnBoardingItem]

var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
VStack {
Text(title)
.font(.largeTitle)
.foregroundColor(style.mainColor)
.fontWeight(.bold)
.padding(.horizontal, 40)
.padding(.vertical, 15)
.multilineTextAlignment(.center)

ScrollView(/*@START_MENU_TOKEN@*/.vertical/*@END_MENU_TOKEN@*/, showsIndicators: false) {
VStack(spacing: 20) {
ForEach(items) {
item in
YLOnBoardingRow(item: item, style: style)
}
}
}
}
.padding(.horizontal, 25)
}
}

struct YLOnBoarding_Previews: PreviewProvider {
static var previews: some View {
YLOnBoarding()
let items = [
YLOnBoardingItem(icon: "bag.fill.badge.plus", title: "New content", description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."),
YLOnBoardingItem(icon: "bag.fill.badge.plus", title: "New content", description: "Discover new content in this update"),
YLOnBoardingItem(icon: "bag.fill.badge.plus", title: "New content", description: "Discover new content in this update")
]
return YLOnBoarding(title: "Discover new features", style: YLOnBoardingStyle(), items: items)
}
}
31 changes: 29 additions & 2 deletions Sources/YLOnBoarding/YLOnBoardingRow.swift
Expand Up @@ -8,13 +8,40 @@
import SwiftUI

struct YLOnBoardingRow: View {

let item: YLOnBoardingItem
let style: YLOnBoardingStyle

private var image: Image {
if let _ = UIImage(named: item.icon) {
return Image(item.icon)
}else{
return Image(systemName: item.icon)
}
}

var body: some View {
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
HStack(alignment: .center) {
image
.font(.largeTitle)
.foregroundColor(style.accentColor)
.frame(maxWidth: 60, alignment: .center)
VStack(alignment: .leading, spacing: 3) {
Text(item.title)
.font(.headline)
.fontWeight(.semibold)
.foregroundColor(style.mainColor)
Text(item.description)
.font(.subheadline)
.foregroundColor(style.mainColor)
}
Spacer()
}
}
}

struct YLOnBoardingRow_Previews: PreviewProvider {
static var previews: some View {
YLOnBoardingRow()
YLOnBoardingRow(item: YLOnBoardingItem(icon: "bag.fill.badge.plus", title: "New content", description: "Discover new content in this update"), style: YLOnBoardingStyle())
}
}
7 changes: 6 additions & 1 deletion Sources/YLOnBoarding/YLOnBoardingStyle.swift
Expand Up @@ -5,4 +5,9 @@
// Created by Yannis Lang on 06/01/2021.
//

import Foundation
import SwiftUI

struct YLOnBoardingStyle {
var mainColor : Color = .black
var accentColor : Color = .blue
}

0 comments on commit fd06e2f

Please sign in to comment.