CarouselView.swift (2925B)
1 // 2 // CarouselView.swift 3 // damus 4 // 5 // Created by William Casarin on 2022-05-20. 6 // 7 8 import SwiftUI 9 10 struct CarouselItem: Identifiable { 11 let image: Image 12 let text: Text 13 14 let id = UUID().uuidString 15 } 16 17 let carousel_items = [ 18 CarouselItem(image: Image("digital-nomad"), text: Text("Welcome to the social network \(Text("you", comment: "You, in this context, is the person who controls their own social network. You is used in the context of a larger sentence that welcomes the reader to the social network that they control themself.").italic()) control.", comment: "Welcoming message to the reader. The variable is 'you', the reader.")), 19 CarouselItem(image: Image("encrypted-message"), 20 text: Text("\(Text("Encrypted", comment: "Heading indicating that this application keeps private messaging end-to-end encrypted.").bold()). End-to-End encrypted private messaging. Keep Big Tech out of your DMs", comment: "Explanation of what is done to keep private data encrypted. There is a heading that precedes this explanation which is a variable to this string.")), 21 CarouselItem(image: Image("undercover"), 22 text: Text("\(Text("Private", comment: "Heading indicating that this application keeps personally identifiable information private. A sentence describing what is done to keep data private comes after this heading.").bold()). Creating an account doesn't require a phone number, email or name. Get started right away with zero friction.", comment: "Explanation of what is done to keep personally identifiable information private. There is a heading that precedes this explanation which is a variable to this string.")), 23 CarouselItem(image: Image("bitcoin-p2p"), 24 text: Text("\(Text("Earn Money", comment: "Heading indicating that this application allows users to earn money.").bold()). Tip your friends and stack sats with Bitcoin⚡️, the native currency of the internet.", comment: "Explanation of what can be done by users to earn money. There is a heading that precedes this explanation which is a variable to this string.")) 25 ] 26 27 struct CarouselView: View { 28 var body: some View { 29 TabView { 30 ForEach(carousel_items) { item in 31 CarouselItemView(item: item) 32 .tabItem { 33 Text(item.id) 34 } 35 } 36 } 37 .tabViewStyle(PageTabViewStyle()) 38 } 39 } 40 41 struct CarouselItemView: View { 42 let item: CarouselItem 43 44 var body: some View { 45 VStack(spacing: 30) { 46 item.image 47 .resizable() 48 .frame(width: 120, height: 120) 49 item.text 50 .multilineTextAlignment(.center) 51 .font(.title2) 52 .foregroundColor(Color.white) 53 .padding([.leading,.trailing], 50.0) 54 .minimumScaleFactor(0.5) 55 } 56 } 57 }