Share
Embed
Transcript
61 slides
-
4XJGU6*ͷΈΛڭ͍͑ͨ w εϧʔͯ͠͠·͍͕ͪͳجૅࣝΛԡ͑͞Δ w ϨΠΞτγεςϜʢαΠζͷܾ·ΓํɺҐஔͷܾ·Γํɺ"MJHONFOUʣ w 7JFXͷण໋ʹ͍ͭͯ !4UBUF!4UBUF0CKFDUͷอ࣋ظؒͳͲ w
7JFX*EFOUJUZ w 4XJGUࣗମͷݴޠػೳʢQSPQFSUZ8SBQQFS ,FZ1BUIͳͲʣ w ͳͲ -
ͲΕ͔ΒखΛ͚͍͍͔ͭͯΘ͔Βͳ͍ w ମܥతʹ·ͱΊΔ w ঢ়ଶཧͷΈʢ!4UBUF !#JOEJOH 0CTFSWBCMF0CKFDU 0CTFSWBUJPOʣ w
/BWJHBUJPO4UBDL/BWJHBUJPO7JFXͷؔੑ طଘࢿྉͷίϐʔʹͳΒͳ͍Α͏͢Δ -
struct SampleView: View { var body: some View { VStack
{ Text("ABC") .foregroundStyle(.blue) .font(.system(size: 14)) Text("DEF") .foregroundStyle(.blue) .font(.system(size: 14)) Text("GHI") .foregroundStyle(.blue) .font(.system(size: 14)) } } } 5FYU͕ͭ͋Δ -
struct SampleView: View { var body: some View { VStack
{ Text("ABC") .foregroundStyle(.blue) .font(.system(size: 14)) Text("DEF") .foregroundStyle(.blue) .font(.system(size: 14)) Text("GHI") .foregroundStyle(.blue) .font(.system(size: 14)) } } } ͦΕͧΕʹಉ͡০Λద༻͍ͯ͠Δ -
struct SampleView: View { var body: some View { VStack
{ Text("ABC") Text("DEF") Text("GHI") } .foregroundStyle(.blue) .font(.system(size: 14)) } } ಉ͡Ͱ͋Ε7JFXʹద༻͢Εͦͷࢠଙͷ7JFXશͯʹ͢Δ -
struct SampleView: View { var body: some View { VStack
{ Text("ABC") Text("DEF") Text("GHI") Text("JKL") .foregroundStyle(.red) } .foregroundStyle(.blue) .font(.system(size: 14)) } } Ұ෦Λม͍͑ͨ߹ͦͷॴʹ.PEJ fi FSΛ͚ͭΕྑ͍͚ͩ શͯͰͳ͍͕͜ΕCVUUPO4UZMFNJOJNVN4DBMF'VDUPSͳͲଞͷ.PEJ fi FSಉ༷ ͜͜·Ͱલఏࣝ ͜ΕΛԠ༻͢Δ -
ྫ͑σβΠϯࢦࣔͷจࣈ৭ͱσϑΥϧτͷจࣈ৭ͷ৭͕ࣅ͍ͯΔ߹ Α͘จࣈ৭Λઃఆ͠Εͯ͠·͍͕ͪ struct ContentView: View { var body: some View
{ VStack { Text("ઃఆࡁΈςΩετ") .foregroundStyle(Color.appText) Text("ઃఆΕςΩετ") //.foregroundStyle(Color.appText) } .font(.system(size: 25)) .bold() } } -
@main struct SwiftUI_TrainingApp: App { var body: some Scene {
WindowGroup { ContentView() .foregroundStyle(.red) // ཱͭ৭Λઃఆ } } } ϧʔτʹ͍ۙՕॴͰGPSFHSPVOE4UZMFΛద༻ -
struct ContentView: View { var body: some View { Color.teal
.frame(width: 100, height: 100) } } GSBNFΛՃ -
struct ContentView: View { var body: some View { Color.teal
.frame(width: 100, height: 100) } } ʮαΠζΛࢦఆ͢Δʯͱ͍͏ ཧղݫີʹͪΐͬͱҧ͏ -
ϨΠΞτγεςϜ w ͜͜·Ͱ88%$ͷηογϣϯʹ͋Δใ w ࣮ࡍͷ࠲ֶͰηογϣϯͰޠΒΕ͍ͯͳ͍༰Χόʔ w GSBNFͷNBY NJO JEFBMܥͷҾ w
fi YFE4J[F w BMJHONFOU(VJEF w ηογϣϯͰܰ͘ྲྀͯͨ͠ͷͰͬͱৄ͘͠ -
struct SNSView: View { let posts = [ ... ]
var body: some View { NavigationView { ScrollView { VStack(spacing: 0) { ForEach(posts) { post in HStack(alignment: .top) { Image(systemName: post.avatar) .resizable() .frame(width: 50, height: 50) .clipShape(Circle()) VStack(alignment: .leading) { HStack { Text(post.username) .font(.headline) Text(post.handle) .font(.subheadline) .foregroundColor(.gray) Spacer() Text(formatDate(post.time)) .font(.subheadline) .foregroundColor(.gray) } Text(post.content) .font(.body) if let imageName = post.image { Image(systemName: imageName) .resizable() .aspectRatio(contentMode: .fit) .frame(maxWidth: .infinity) ࣮श՝ͷྫϦϑΝΫλϦϯάνϟϨϯδ -
struct SNSView: View { let posts = [ ... ]
var body: some View { NavigationView { ScrollView { VStack(spacing: 0) { ForEach(posts) { post in HStack(alignment: .top) { Image(systemName: post.avatar) .resizable() .frame(width: 50, height: 50) .clipShape(Circle()) VStack(alignment: .leading) { HStack { Text(post.username) .font(.headline) Text(post.handle) .font(.subheadline) .foregroundColor(.gray) Spacer() Text(formatDate(post.time)) .font(.subheadline) .foregroundColor(.gray) } Text(post.content) .font(.body) if let imageName = post.image { Image(systemName: imageName) .resizable() .aspectRatio(contentMode: .fit) .frame(maxWidth: .infinity) ࣮श՝ͷྫϦϑΝΫλϦϯάνϟϨϯδ ϋϦϘςͷ7JFXΛ༻ҙ -
struct SNSView: View { let posts = [ ... ]
var body: some View { NavigationView { ScrollView { VStack(spacing: 0) { ForEach(posts) { post in HStack(alignment: .top) { Image(systemName: post.avatar) .resizable() .frame(width: 50, height: 50) .clipShape(Circle()) VStack(alignment: .leading) { HStack { Text(post.username) .font(.headline) Text(post.handle) .font(.subheadline) .foregroundColor(.gray) Spacer() Text(formatDate(post.time)) .font(.subheadline) .foregroundColor(.gray) } Text(post.content) .font(.body) if let imageName = post.image { Image(systemName: imageName) .resizable() .aspectRatio(contentMode: .fit) .frame(maxWidth: .infinity) ࣮श՝ͷྫϦϑΝΫλϦϯάνϟϨϯδ શͯͷϨΠΞτΛΘ͟ͱCPEZʹू େମߦ͙Β͍͋Δ -
import SwiftUI struct Post: Identifiable { let id = UUID()
let username: String let handle: String let time: Date let content: String let avatar: String let retweets: Int let likes: Int let comments: Int let views: Int let image: String? } struct SNSView: View { let posts = [ Post( username: "John Doe", handle: "@johndoe", time: Date(), content: "μϯλϯͷ৽͍͠ΧϑΣͰ࠷ߴͷίʔώʔΛҿΈ·ͨ͠ʂ", avatar: "person.circle", retweets: 12, likes: 34, comments: 5, views: 120, image: nil ), Post( username: "Jane Smith", handle: "@janesmith", time: Date().addingTimeInterval(-3600), content: "࠷৽ͷιϑτΣΞΞοϓσʔτͷ৽ػೳ͕େ͖Ͱ͢ʂ", avatar: "person.circle.fill", retweets: 20, likes: 55, comments: 8, views: 200, image: nil ), Post( username: "Alice Johnson", handle: "@alicej", time: Date().addingTimeInterval(-7200), content: "ࠓͷϏʔνͰͷඒ͍͠༦ɻ", avatar: "person", retweets: 18, likes: 45, comments: 3, views: 180, image: "sun.max" ), Post( username: "Bob Brown", handle: "@bobb", time: Date().addingTimeInterval(-86400), content: "ࠓேͷૉΒ͍͠ϫʔΫΞτηογϣϯɻ", avatar: "person.crop.circle", retweets: 10, likes: 30, comments: 2, views: 150, image: "figure.walk" ), Post( username: "Charlie Davis", handle: "@charlied", time: Date().addingTimeInterval(-172800), content: "ྺ࢙ʹؔ͢Δڵຯਂ͍ຊΛಡΜͰ͍·͢ɻ", avatar: "person.crop.circle.fill", retweets: 25, likes: 60, comments: 10, views: 220, image: nil ), Post( username: "Dana Lee", handle: "@danalee", time: Date().addingTimeInterval(-259200), content: "ࠓ͓͍͍͠ΫοΩʔΛম͖·ͨ͠ɻ", avatar: "person.circle", retweets: 15, likes: 50, comments: 6, views: 170, image: nil ), Post( username: "Evan Green", handle: "@evangreen", time: Date().addingTimeInterval(-345600), content: "ࢁͰϋΠΩϯάʹߦ͖·ͨ͠ɻͱͯϦϑϨογϡ͠·ͨ͠ʂ", avatar: "person.circle.fill", retweets: 22, likes: 58, comments: 9, views: 210, image: nil ), Post( username: "Fiona White", handle: "@fionawhite", time: Date().addingTimeInterval(-432000), content: "৽͍͠ςϨϏγϦʔζΛݟ͍ͯ·͢ɻຊʹ໘ന͍Ͱ͢ʂ", avatar: "person", retweets: 30, likes: 75, comments: 12, views: 240, image: nil ), Post( username: "George King", handle: "@georgek", time: Date().addingTimeInterval(-518400), content: "ࠓͷσΟφʔͷͨΊʹ৽͍͠ϨγϐΛࢼ͍ͯ͠·͢ɻ", avatar: "person.crop.circle", retweets: 14, likes: 40, comments: 4, views: 160, image: nil ), Post( username: "Hannah Scott", handle: "@hannahs", time: Date().addingTimeInterval(-604800), content: "ࠓതؗΛ๚Ε·ͨ͠ɻͨ͘͞Μͷັྗతͳల͕ࣔ͋Γ·ͨ͠ɻ", avatar: "person.crop.circle.fill", retweets: 28, likes: 70, comments: 11, views: 230, image: "building.columns" ) ] var body: some View { NavigationView { ScrollView { VStack(spacing: 0) { ForEach(posts) { post in HStack(alignment: .top) { Image(systemName: post.avatar) .resizable() .frame(width: 50, height: 50) .clipShape(Circle()) VStack(alignment: .leading) { HStack { Text(post.username) .font(.headline) Text(post.handle) .font(.subheadline) .foregroundColor(.gray) Spacer() Text(formatDate(post.time)) .font(.subheadline) .foregroundColor(.gray) } Text(post.content) .font(.body) if let imageName = post.image { Image(systemName: imageName) .resizable() .aspectRatio(contentMode: .fit) .frame(maxWidth: .infinity) .padding(.horizontal) } HStack { Button { } label: { HStack { Image(systemName: "message") Text("\(post.comments)") } } Spacer() Button { } label: { HStack { Image(systemName: "arrow.2.squarepath") Text("\(post.retweets)") } } Spacer() Button { } label: { HStack { Image(systemName: "heart") Text("\(post.likes)") } } Spacer() HStack { Image(systemName: "eye") Text("\(post.views)") } } .foregroundColor(.gray) .padding([.horizontal, .bottom], 10) } } .padding([.horizontal, .top], 10) Divider() } } } .navigationBarTitle("ϗʔϜ", displayMode: .inline) .overlay { HStack { Spacer() VStack { Spacer() Button { } label: { Image(systemName: "plus") .resizable() .frame(width: 24, height: 24) .padding() .background(Color.blue) .foregroundColor(.white) .clipShape(Circle()) .shadow(radius: 10) } .padding() } } } } } func formatDate(_ date: Date) -> String { let formatter = RelativeDateTimeFormatter() formatter.unitsStyle = .short return formatter.localizedString(for: date, relativeTo: Date()) } } #Preview { SNSView() } શ෦ग़͢ͱ͜Μͳײ͡ ͜ΕΛෳͷ7JFXϑΝΠϧʹׂͯ͠Β͏