Create row for list of words
This commit is contained in:
		| @@ -14,6 +14,7 @@ | |||||||
| 		6C8185062B8A537F0033CF46 /* WordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185052B8A537F0033CF46 /* WordView.swift */; }; | 		6C8185062B8A537F0033CF46 /* WordView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185052B8A537F0033CF46 /* WordView.swift */; }; | ||||||
| 		6C8185082B8B523E0033CF46 /* NextRepetitionButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */; }; | 		6C8185082B8B523E0033CF46 /* NextRepetitionButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */; }; | ||||||
| 		6C81850A2B8BA5740033CF46 /* WordListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185092B8BA5740033CF46 /* WordListView.swift */; }; | 		6C81850A2B8BA5740033CF46 /* WordListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C8185092B8BA5740033CF46 /* WordListView.swift */; }; | ||||||
|  | 		6C81850C2B8BA6BC0033CF46 /* WordListRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C81850B2B8BA6BC0033CF46 /* WordListRowView.swift */; }; | ||||||
| 		6CF439522B83541D004C3543 /* WordAXApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CF439512B83541D004C3543 /* WordAXApp.swift */; }; | 		6CF439522B83541D004C3543 /* WordAXApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CF439512B83541D004C3543 /* WordAXApp.swift */; }; | ||||||
| 		6CF439542B83541D004C3543 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CF439532B83541D004C3543 /* MainView.swift */; }; | 		6CF439542B83541D004C3543 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CF439532B83541D004C3543 /* MainView.swift */; }; | ||||||
| 		6CF439562B83541E004C3543 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6CF439552B83541E004C3543 /* Assets.xcassets */; }; | 		6CF439562B83541E004C3543 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6CF439552B83541E004C3543 /* Assets.xcassets */; }; | ||||||
| @@ -28,6 +29,7 @@ | |||||||
| 		6C8185052B8A537F0033CF46 /* WordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordView.swift; sourceTree = "<group>"; }; | 		6C8185052B8A537F0033CF46 /* WordView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordView.swift; sourceTree = "<group>"; }; | ||||||
| 		6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextRepetitionButtonView.swift; sourceTree = "<group>"; }; | 		6C8185072B8B523D0033CF46 /* NextRepetitionButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextRepetitionButtonView.swift; sourceTree = "<group>"; }; | ||||||
| 		6C8185092B8BA5740033CF46 /* WordListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordListView.swift; sourceTree = "<group>"; }; | 		6C8185092B8BA5740033CF46 /* WordListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordListView.swift; sourceTree = "<group>"; }; | ||||||
|  | 		6C81850B2B8BA6BC0033CF46 /* WordListRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordListRowView.swift; sourceTree = "<group>"; }; | ||||||
| 		6CF4394E2B83541D004C3543 /* WordAX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WordAX.app; sourceTree = BUILT_PRODUCTS_DIR; }; | 		6CF4394E2B83541D004C3543 /* WordAX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WordAX.app; sourceTree = BUILT_PRODUCTS_DIR; }; | ||||||
| 		6CF439512B83541D004C3543 /* WordAXApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordAXApp.swift; sourceTree = "<group>"; }; | 		6CF439512B83541D004C3543 /* WordAXApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordAXApp.swift; sourceTree = "<group>"; }; | ||||||
| 		6CF439532B83541D004C3543 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; }; | 		6CF439532B83541D004C3543 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; }; | ||||||
| @@ -68,6 +70,7 @@ | |||||||
| 				6CF439512B83541D004C3543 /* WordAXApp.swift */, | 				6CF439512B83541D004C3543 /* WordAXApp.swift */, | ||||||
| 				6CF439532B83541D004C3543 /* MainView.swift */, | 				6CF439532B83541D004C3543 /* MainView.swift */, | ||||||
| 				6C8185092B8BA5740033CF46 /* WordListView.swift */, | 				6C8185092B8BA5740033CF46 /* WordListView.swift */, | ||||||
|  | 				6C81850B2B8BA6BC0033CF46 /* WordListRowView.swift */, | ||||||
| 				6C8185012B88C9FB0033CF46 /* SettingsView.swift */, | 				6C8185012B88C9FB0033CF46 /* SettingsView.swift */, | ||||||
| 				6C8185032B88CA210033CF46 /* AnkiView.swift */, | 				6C8185032B88CA210033CF46 /* AnkiView.swift */, | ||||||
| 				6C8185052B8A537F0033CF46 /* WordView.swift */, | 				6C8185052B8A537F0033CF46 /* WordView.swift */, | ||||||
| @@ -167,6 +170,7 @@ | |||||||
| 				6C8185042B88CA210033CF46 /* AnkiView.swift in Sources */, | 				6C8185042B88CA210033CF46 /* AnkiView.swift in Sources */, | ||||||
| 				6CF439522B83541D004C3543 /* WordAXApp.swift in Sources */, | 				6CF439522B83541D004C3543 /* WordAXApp.swift in Sources */, | ||||||
| 				6C8184FE2B88C9580033CF46 /* WordAX.swift in Sources */, | 				6C8184FE2B88C9580033CF46 /* WordAX.swift in Sources */, | ||||||
|  | 				6C81850C2B8BA6BC0033CF46 /* WordListRowView.swift in Sources */, | ||||||
| 			); | 			); | ||||||
| 			runOnlyForDeploymentPostprocessing = 0; | 			runOnlyForDeploymentPostprocessing = 0; | ||||||
| 		}; | 		}; | ||||||
|   | |||||||
							
								
								
									
										57
									
								
								WordAX/WordListRowView.swift
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								WordAX/WordListRowView.swift
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | |||||||
|  | // | ||||||
|  | //  WordListRowView.swift | ||||||
|  | //  WordAX | ||||||
|  | // | ||||||
|  | //  Created by Oliver Hnát on 25.02.2024. | ||||||
|  | // | ||||||
|  |  | ||||||
|  | import SwiftUI | ||||||
|  |  | ||||||
|  | struct WordListRowView: View { | ||||||
|  |     @EnvironmentObject var model: WordAXModelView | ||||||
|  |     var word: WordAX.Word | ||||||
|  |     @State var favorite = true | ||||||
|  |     var body: some View { | ||||||
|  |         HStack { | ||||||
|  |             Group { | ||||||
|  |                 if favorite { | ||||||
|  |                     Image(systemName: "star") | ||||||
|  |                 } else { | ||||||
|  |                     ZStack { | ||||||
|  |                         Image(systemName: "star.fill") | ||||||
|  |                             .foregroundStyle(.yellow) | ||||||
|  |                         Image(systemName: "star") | ||||||
|  |                             .opacity(0.4) | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             .onTapGesture { | ||||||
|  |                 self.favorite = !self.favorite | ||||||
|  |             } | ||||||
|  |             .padding(.trailing) | ||||||
|  |             VStack { | ||||||
|  |                 Text(word.name) | ||||||
|  |                     .bold() | ||||||
|  |                     .font(.system(size: 19)) | ||||||
|  |                     .multilineTextAlignment(.leading) | ||||||
|  |                     .frame(maxWidth: .infinity, alignment: .leading) | ||||||
|  |                 Text(word.description) | ||||||
|  |                     .multilineTextAlignment(.leading) | ||||||
|  |                     .frame(maxWidth: .infinity, alignment: .leading) | ||||||
|  |                     .lineLimit(1) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #Preview { | ||||||
|  |     Group { | ||||||
|  |         WordListRowView(word: WordAX.Word(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1)) | ||||||
|  |             .environmentObject(WordAXModelView()) | ||||||
|  |         WordListRowView(word: WordAX.Word(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1)) | ||||||
|  |             .environmentObject(WordAXModelView()) | ||||||
|  |         WordListRowView(word: WordAX.Word(id: 0, name: "Mesmerizing", description: "Some very long description like Lorem Ipsum which I'm to lazy to copy", shown: false, nextSpacedRepetitionMilestone: WordAX.SpacedRepetitionMilestoneEnum.OneDay, lastSeenOn: Date(), shownCount: 1)) | ||||||
|  |             .environmentObject(WordAXModelView()) | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user