-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ongoing work for the TestFlight version of the "GamesAndThings" app.
- Loading branch information
Showing
19 changed files
with
364 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
...ctSomeMore.xcodeproj/xcuserdata/ajolicoeur.xcuserdatad/xcschemes/xcschememanagement.plist
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
CollectSomeMore/Assets.xcassets/AccentColor.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+260 KB
CollectSomeMore/Assets.xcassets/AppIcon.appiconset/AppIcon_GamesAndThings_iOS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
CollectSomeMore/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// | ||
// ComicsData.swift | ||
// GamesAndThings | ||
// | ||
// Created by Adam Jolicoeur on 7/2/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
// Step 1: Define a comics Model | ||
struct Comic: Identifiable { | ||
let id = UUID() | ||
let title: String | ||
let genre: String | ||
let description: String | ||
} | ||
|
||
// Step 2: Extend the ComicsViewModel | ||
class ComicViewModel: ObservableObject { | ||
@Published var comic: [Comic] = [ | ||
Comic(title: "Inception", genre: "Science Fiction", description: "A thief who steals corporate secrets through the use of dream-sharing technology is given the inverse task of planting an idea into the mind of a CEO."), | ||
Comic(title: "The Shawshank Redemption", genre: "Drama", description: "Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency."), | ||
Comic(title: "The Dark Knight", genre: "Action", description: "When the menace known as the Joker emerges from his mysterious past, he wreaks havoc and chaos on the people of Gotham."), | ||
] | ||
|
||
// Method to add a new comic | ||
func addComic(title: String, genre: String, description: String) { | ||
let newComic = Comic(title: title, genre: genre, description: description) | ||
comic.append(newComic) | ||
} | ||
} | ||
|
||
// Step 3: Build the ComicView | ||
struct ComicView: View { | ||
var comic: Comic | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 10) { | ||
// Text(comic.title) | ||
// .font(.headline) | ||
// .foregroundColor(.primary) | ||
Label("Genre: \(comic.genre)", systemImage: "popcorn") | ||
.labelStyle(.titleAndIcon) | ||
.font(.subheadline) | ||
// Text("Genre: \(comic.genre)") | ||
// .font(.subheadline) | ||
// .foregroundColor(.secondary) | ||
|
||
Text(comic.description) | ||
.font(.body) | ||
.foregroundColor(.secondary) | ||
} | ||
.padding() | ||
.background(Color(UIColor.systemGray6)) | ||
.cornerRadius(8) | ||
.shadow(radius: 2) | ||
} | ||
} | ||
|
||
// Step 4: Create the ComicsFormView | ||
struct ComicFormView: View { | ||
@Environment(\.presentationMode) var presentationMode | ||
@ObservedObject var viewModel: ComicViewModel | ||
@State private var title: String = "" | ||
@State private var genre: String = "" | ||
@State private var description: String = "" | ||
|
||
var body: some View { | ||
NavigationView { | ||
Form { | ||
Section(header: Text("Comic Details")) { | ||
TextField("Title", text: $title) | ||
TextField("Genre", text: $genre) | ||
TextField("Description", text: $description) | ||
} | ||
|
||
Button(action: { | ||
viewModel.addComic(title: title, genre: genre, description: description) | ||
presentationMode.wrappedValue.dismiss() | ||
}) { | ||
Text("Add comics") | ||
} | ||
.disabled(title.isEmpty || genre.isEmpty || description.isEmpty) | ||
} | ||
.navigationTitle("Add New comics") | ||
} | ||
} | ||
} | ||
|
||
// Step 5: Update the Main View | ||
struct ComicListView: View { | ||
@StateObject private var viewModel = ComicViewModel() | ||
@State private var showingForm = false | ||
|
||
var body: some View { | ||
NavigationView { | ||
List(viewModel.comic) { comic in | ||
NavigationLink { | ||
ComicView(comic: comic) | ||
} label: { | ||
Text(comic.title) | ||
} | ||
ComicView(comic: comic) | ||
.padding(.vertical, 5) | ||
} | ||
.navigationTitle("Comics") | ||
.toolbar { | ||
ToolbarItem(placement: .navigationBarTrailing) { | ||
Button(action: { | ||
showingForm.toggle() | ||
}) { | ||
Image(systemName: "plus") | ||
} | ||
.sheet(isPresented: $showingForm) { | ||
ComicFormView(viewModel: viewModel) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Preview | ||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ComicListView() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Gamesandthings.swift | ||
// Games and Things - tracking your collections across gaming genres. | ||
// | ||
// Created by Adam Jolicoeur on 6/7/24. | ||
// | ||
|
||
import Foundation | ||
import SwiftData | ||
|
||
@Model | ||
final class Movie { | ||
var id: UUID | ||
var title: String | ||
var releaseDate: Date | ||
var purchaseDate: Date | ||
var genre: String | ||
var imageData: Data? | ||
|
||
init(id: UUID = UUID(), title: String, releaseDate: Date, purchaseDate: Date, genre: String, imageData: Data? = nil) { | ||
self.id = id | ||
self.title = title | ||
self.releaseDate = releaseDate | ||
self.purchaseDate = purchaseDate | ||
self.genre = genre | ||
self.imageData = imageData | ||
} | ||
|
||
static let sampleData = [ | ||
Movie(id: UUID(), title: "Deadpool", | ||
releaseDate: Date(timeIntervalSinceReferenceDate: -402_00_00), | ||
purchaseDate: Date(timeIntervalSinceNow: -5_000_000), | ||
genre: "Superhero"), | ||
Movie(id: UUID(), title: "Deadpool & Wolverine", | ||
releaseDate: Date(timeIntervalSinceReferenceDate: -20_000_000), | ||
purchaseDate: Date(timeIntervalSinceNow: -5_000_000), | ||
genre: "Comedy") | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,17 @@ | ||
// | ||
// Movie.swift | ||
// CollectSomeMore | ||
// | ||
// Created by Adam Jolicoeur on 6/7/24. | ||
// | ||
import SwiftUI | ||
|
||
import Foundation | ||
import SwiftData | ||
|
||
@Model | ||
final class Movie { | ||
var title: String | ||
var releaseDate: Date | ||
|
||
init(title: String, releaseDate: Date) { | ||
self.title = title | ||
self.releaseDate = releaseDate | ||
} | ||
|
||
static let sampleData = [ | ||
Movie(title: "Amusing Space Traveler 3", | ||
releaseDate: Date(timeIntervalSinceReferenceDate: -402_00_00)), | ||
Movie(title: "Difficult Cat", | ||
releaseDate: Date(timeIntervalSinceReferenceDate: -20_000_000)), | ||
Movie(title: "Electrifying Trek", | ||
releaseDate: Date(timeIntervalSinceReferenceDate: 300_000_000)), | ||
Movie(title: "Reckless Train Ride 2", | ||
releaseDate: Date(timeIntervalSinceReferenceDate: 120_000_000)), | ||
Movie(title: "The Last Venture", | ||
releaseDate: Date(timeIntervalSinceReferenceDate: 550_000_000)), | ||
Movie(title: "Glamorous Neighbor", | ||
releaseDate: Date(timeIntervalSinceReferenceDate: 700_000_000)) | ||
] | ||
} | ||
//class Movie: ObservableObject { | ||
// @Published var title: String | ||
// @Published var releaseDate: Date | ||
// @Published var purchaseDate: Date | ||
// @Published var genre: String | ||
// @Published var imageData: Data? | ||
// | ||
// init(title: String, releaseDate: Date, purchaseDate: Date, genre: String, imageData: Data? = nil) { | ||
// self.title = title | ||
// self.releaseDate = releaseDate | ||
// self.purchaseDate = purchaseDate | ||
// self.genre = genre | ||
// self.imageData = imageData | ||
// } | ||
//} |
Oops, something went wrong.