tutorial101 is the one place for high quality web development, Web Design and software development tutorials and Resources programming. Learn cutting edge techniques in web development, design and software development, download source components and participate in the community.
//
// Detail.swift
// Test
//
// Created by Cairocoders
//
import SwiftUI
struct Detail : View {
@Binding var show : Bool
var body : some View{
VStack(spacing: 15){
HStack(spacing: 15){
Button(action: {
self.show.toggle()
}) {
Image(systemName: "arrow.left").foregroundColor(Color.white)
}
Spacer()
Button(action: {
actionSheet()
}) {
Image("share").renderingMode(.original)
}
Button(action: {
}) {
Image(systemName: "info.circle").foregroundColor(Color.white)
}
}.padding()
ZStack{
Image("detail").resizable()
VStack(alignment: .leading,spacing: 12){
Spacer()
Text("ACTION")
Text("Journey 2: The Mysterious Island").font(.title)
HStack(spacing: 10){
Text("98% Match")
Text("2012")
Image("hd")
Spacer()
}
}.padding()
}.frame(height: UIScreen.main.bounds.height / 2)
.navigationBarTitle("")
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
ScrollView(.vertical, showsIndicators: false) {
VStack(alignment: .leading, spacing: 15){
HStack{
Button(action: {
}) {
HStack(spacing: 10){
Image(systemName: "play.fill")
Text("Play")
}.padding()
}.foregroundColor(.white)
.background(Color.red)
.cornerRadius(10)
Button(action: {
}) {
HStack(spacing: 10){
Image(systemName: "plus")
Text("ADD TO LIST")
}.padding()
}.foregroundColor(.white)
.background(Color.gray)
.cornerRadius(10)
Spacer()
}
HStack{
VStack(alignment: .leading, spacing: 10){
Text("Journey 2: The Mysterious Island")
Text("Sean Anderson partners with his mom's husband on a mission to find his grandfather, who is thought to be missing on a mythical island.").foregroundColor(.gray)
}
}.padding(.top, 15)
Divider().padding(.vertical, 12)
ForEach(popular){i in
VStack(alignment: .leading,spacing: 15){
HStack{
Image(i.image)
.resizable().aspectRatio(contentMode: .fill)
VStack(alignment: .leading, spacing: 10){
Text(i.name)
Text(i.time)
}
Spacer()
Button(action: {
}) {
Image(systemName: "arrow.down")
}
}
Text(i.desc)
}
}.padding(.bottom, 15)
}
}.padding(.top, 15)
.padding(.horizontal, 15)
}.edgesIgnoringSafeArea(.bottom)
}
func actionSheet() {
guard let urlShare = URL(string: "https://developer.apple.com/xcode/swiftui/") else { return }
let activityVC = UIActivityViewController(activityItems: [urlShare], applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController?.present(activityVC, animated: true, completion: nil)
}
}
struct Detail_Previews: PreviewProvider {
@State static var show = false
static var previews: some View {
Detail(show: $show)
}
}
Model.swift
//
// Model.swift
// Test
//
// Created by Cairocoders
//
import SwiftUI
struct type : Identifiable {
var id : Int
var name : String
var image : String
var percentage : CGFloat
}
var datas = [
type(id: 0, name: "The Amazing Spider-Man", image: "1",percentage : 45),
type(id: 1, name: "Fast and Furious Presents", image: "2",percentage: 90),
type(id: 2, name: "Green Snake", image: "3",percentage: 53)
]
var bottom = ["b1","b2"]
struct polularlist : Identifiable {
var id : Int
var name : String
var time : String
var image : String
var desc : String
}
var popular = [polularlist(id: 0, name: "Green Snake", time: "51 min", image: "3", desc: "While trying to free her sister from Fahai's clutches, Xio Qing winds up in a dystopian city and meets a mysterious man who can't recall his past life."),
polularlist(id: 1, name: "How to Train Your Dragon 2", time: "44 min", image: "4", desc: "Five years have passed since Hiccup and Toothless united the dragons and Vikings of Berk. Now, they spend their time charting the island's unmapped territories. During one of their adventures, the pair discover a secret cave that houses hundreds of wild dragons"),
polularlist(id: 2, name: "Aquaman", time: "63 min", image: "5", desc: "Once home to the most advanced civilization on Earth, the city of Atlantis is now an underwater kingdom ruled by the power-hungry King Orm. With a vast army at his disposal, Orm plans to conquer the remaining oceanic people -- and then the surface world.")]