@@ -154,43 +154,40 @@ adding `.gesture(DragGesture ...)` at the end of your board view.
## Task 6: TabView
You should create a `TabView` in your ContentView.swift, and include
three views inside the TabView. The first one should be your board
view, and we will work on the second and third views later on.
You should create a `TabView` in your ContentView.swift with three subviews. The first should be your board
view, the second the high scores, and the third is your "About" screen.
## Task 7: Implement the *HighScores* Page
### For Model:
1. Create a new data structure Score which includes at least two variables. You will use this data structure to record each game's result. You may want to add more variables and methods as needed. `Hashable` is not necessary but it can make our lives easier to sort a list of Score. An example of this data structure is:
### For the Score Model:
1. Create a new data structure *Score* to record each game's result. You may want to add more variables and methods as needed. `Hashable` is not necessary but makes it much easier to sort the list. The following is an example of this data structure:
```
struct Score: Hashable {
var score: Int
var time: Date
func hash(into hasher: inout Hasher) {
hasher.combine(time)
}
init(score: Int, time: Date) {
self.score = score
self.time = time
}
}
struct Score: Hashable {
var score: Int
var time: Date
func hash(into hasher: inout Hasher) {
hasher.combine(time)
}
init(score: Int, time: Date) {
self.score = score
self.time = time
}
}
```
2. Create a list of Score, which will record all previous games'
results. Add 2 initial data (score = 300 and 400, while date
time can be any time) to this list when the app gets
initiated. This means that we should see two results in the
score page even we never played any one game.
2. Create a high scores list. Add two initial entries (score = 300 and 400, while date
time can be any time) to this list when the app gets
initiated. This means that we should see two results in the
score page even if we never played a game.
3. Sorting the list. You can do the sorting when the score page appears or each new data point is added to the Score list.
3. Sort the list. You can perform the sorting when the score page appears, or when new data points are added.
### For View:
You should:
- Create a new file called "Scores.swift", and create a view called `Scores`.
- Include a `List View` in this view, and use `ForEach` to traversal through the Score list we just created in the model to show the data of each game. You should include the rank, the score, and the date time of each data point.
### For The Score View:
- Create a new file called "Scores.swift", and create a view called `ScoresView`.
- Use a List to show high scores. Include the rank, the score, and the datetime of each data point.
**Important** The score should be sorted from high to low on the list. The data time can be any format, but should include all the information of "hour, minute, second, date and year'.
**Important:** The scores must be sorted. The datetime can be any format, but should include both the time and the date.
## Task 8: Implement the *About* Page
It doesn't have to be like mine, and it doesn't have to use gestures, but it
...
...
@@ -198,20 +195,19 @@ should be fancy. Use `Path.addCurve()` or `CGPath` to draw something a diagram,
mini-game or animation, be creative!
## Task 9: Portrait vs. Landscape
Until now, we only implement the app based on a Portrait-position
screen. We should implement the app in a Landscape screen as well.
You can create variables
So far we have assumed portrait orientation. Your game should work in landscape as well.
You can create variables:
```
@Environment(\.verticalSizeClass) var verticalSizeClass
@Environment(\.horizontalSizeClass) var horizontalSizeClass
@Environment(\.verticalSizeClass) var verticalSizeClass
@Environment(\.horizontalSizeClass) var horizontalSizeClass
```
to check the current orientation of the screen and modify the View
accordingly. We will test your work by rotating the screen, we
should see the position of game board and buttons arearranged well
on each screen orientation.
accordingly. We will test your work by rotating the screen; we
should see the position of game board and buttons rearrange
at each orientation change.
## Grading
Note that the above tasks are for sequencing your work. They do not match up exactly with this grading rubric:
The task enumeration above is to aid you in planning your work. The grading scheme below is a bit different: