Skip to content

Commit

Permalink
update example view
Browse files Browse the repository at this point in the history
  • Loading branch information
devmehmetates committed Apr 17, 2023
1 parent 5733546 commit e5063dd
Showing 1 changed file with 26 additions and 147 deletions.
173 changes: 26 additions & 147 deletions Sources/SwiftyKit/ExampleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,172 +8,51 @@
import SwiftUI

#if DEBUG
@available(iOS 13.0, *)
struct ExampleView_Previews: PreviewProvider {
static var previews: some View {
GenericUIViewControllerRepresentable { _ in
UINavigationController(rootViewController: ExampleView())
}
}
}

@available(iOS 13.0, *)
final class ExampleView: UIViewController {
var images = [
"https://media-rockstargames-com.akamaized.net/rockstargames-newsite/img/global/downloads/buddyiconsconavatars/v_casino_heist2_256x256.jpg",
"https://media-rockstargames-com.akamaized.net/rockstargames-newsite/img/global/downloads/buddyiconsconavatars/v_casino_heist3_256x256.jpg",
"https://media-rockstargames-com.akamaized.net/rockstargames-newsite/img/global/downloads/buddyiconsconavatars/v_doomsdayheist2_256x256.jpg",
"https://media-rockstargames-com.akamaized.net/rockstargames-newsite/img/global/downloads/buddyiconsconavatars/v_gunrunning_girl_256x256.jpg",
"https://media-rockstargames-com.akamaized.net/rockstargames-newsite/img/global/downloads/buddyiconsconavatars/v_halloweensurprise_girl_256x256.jpg"
]

override func viewDidLoad() {
super.viewDidLoad()

title = "Metin"
navigationController?.navigationBar.prefersLargeTitles = true
navigationController?.navigationBar.backgroundColor = .systemBackground
view.backgroundColor(.gray.withAlphaComponent(0.1))
self.title = "Navigation Title"
self.navigationController?.navigationBar.prefersLargeTitles = true
createView()
}

func createView() {
BaseScrollView {
VerticalStack {
UIImageView()
.imageSystemName("applelogo")
.contentMode(.scaleAspectFit)
.padding(.top)

for (index, image) in images.lazy.enumerated() {
createProfileCard(image, title: "Avatar: \(index)")
}

BaseTextField()
.placeholder("Metin")
.onEdit { text in
self.title = text
}
.padding(.horizontal)

BaseButton(type: .system)
.setTitle("Değiştir")
VerticalStack {
UILabel()
.text("Section Title")
.font(.systemFont(ofSize: 14))
.textColor(.gray)
.padding(padding: 5)
.padding(.horizontal)

for num in 0...2 {
stackCreator("Key: \(num)", description: "Value")
}
}
VerticalStack {
for num in 0...2 {
stackCreator("Key: \(num)", description: "Value")
}
for _ in 0...10 {
HorizontalStack {
createCardRow("Row", image: "https://picsum.photos/200")
createCardRow("Row", image: "https://picsum.photos/200")
}.frame(width: 90.0.responsiveW)
.distribution(.equalSpacing)
}

VerticalStack {
for num in 0...20 {
stackCreator("Key: \(num)", description: "Value")
}
}

BaseButton(type: .system)
.setTitle("Onay")
.backgroundColor(.white)
.tintColor(.red)
.height(56)
.cornerRadius(10)
.stroke(borderColor: .black.withAlphaComponent(0.2))
.padding(.horizontal)
}.spacing(20)
}
}.addView(view)
.fillToSuperView()
}

func createProfileCard(_ image: String, title: String) -> UIView {
HorizontalStack {
UIImageView()
.asyncImage(URL(string: image))
.contentMode(.scaleAspectFit)
.clipsToBounds(true)
.frame(width: 50, height: 50)
.backgroundColor(.gray.withAlphaComponent(0.2))
.cornerRadius(10)
UILabel(title)
.textColor(.red)
.font(.systemFont(ofSize: 12, weight: .light))
Spacer()
BaseButton(type: .system)
.didClick {
let vc = UIViewController()
vc.view.backgroundColor = .systemBackground
vc.navigationController?.navigationBar.prefersLargeTitles = false
vc.view.backgroundColor(.blue)
UIImageView()
.asyncImage(URL(string: image))
.contentMode(.scaleAspectFill)
.addView(vc.view)
.centerToSuperview()
self.navigationController?.pushViewController(vc, animated: true)
}
.setTitle("Detail")
.padding(.horizontal)
}.spacing(10)
.backgroundColor(.systemBackground)
.cornerRadius(10)
.shadow()
.padding(.horizontal)

}

func createAdvantageCard(_ image: String) -> UIView {
private func createCardRow(_ title: String, image: String) -> UIView {
VerticalStack {
UIImageView()
.asyncImage(URL(string: image))
.contentMode(.scaleAspectFill)
.clipsToBounds(true)
HorizontalStack {
UISwitch()
Spacer()
UILabel()
.text("Avantajı Seç")
.padding(.horizontal)
}.alignment(.center)
.height(50)
.padding(.leading)
}.height(200)
.cornerRadius(10)
.backgroundColor(.systemBackground)
.padding(.horizontal)
.shadow(offset: CGSize(width: 0, height: 9))
}

func stackCreator(_ title: String, description: String) -> UIView {

HorizontalStack {
UILabel()
.text(title)
.font(.systemFont(ofSize: 16, weight: .bold))
Spacer()
UILabel()
.text(description)
.font(.systemFont(ofSize: 16))
.frame(width: 35.0.responsiveW, height: 35.0.responsiveW)
UILabel("History")
.font(.boldSystemFont(ofSize: 15))
}.padding()
.backgroundColor(.systemBackground)
.cornerRadius(10)
.padding(.horizontal)
.padding(.vertical, padding: 5)
.shadow()

}
}

@available(iOS 13.0, *)
struct ExampleView_Previews: PreviewProvider {
static var previews: some View {
GenericUIViewControllerRepresentable { _ in
UINavigationController(rootViewController: ExampleView())
}
}
}
#endif

extension String {
static var exampleText =
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam facilisis ipsum id ornare finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Duis vitae metus ut lectus pulvinar facilisis. Etiam pretium, nulla ut blandit facilisis, risus est porttitor mauris, vitae aliquam nisi lorem sit amet ante. Ut suscipit orci quis erat accumsan finibus. Mauris in mi et elit varius posuere. Morbi lacinia nisi eget nisi lacinia tempus. Sed a egestas tellus, sit amet vulputate mauris. Aenean efficitur nec eros vel aliquam. In non ligula pharetra, ullamcorper ligula et, rhoncus nisi. Mauris ullamcorper mi purus, ullamcorper consectetur orci tempor a. Vestibulum quis semper nunc. Praesent malesuada ornare leo, vestibulum euismod nisl dignissim vel.
"""
}

0 comments on commit e5063dd

Please sign in to comment.