-
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.
🔀 Merge branch 'ladislas/feature/lekaapp-list-sample-activities'
- Loading branch information
Showing
13 changed files
with
194 additions
and
10 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
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
138 changes: 138 additions & 0 deletions
138
Apps/LekaApp/Sources/_NEWCodeBase/Views/Activities/ActivityDetailsView.swift
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,138 @@ | ||
// Leka - iOS Monorepo | ||
// Copyright APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import ContentKit | ||
import MarkdownUI | ||
import SwiftUI | ||
|
||
// MARK: - ActivityDetailsView | ||
|
||
struct ActivityDetailsView: View { | ||
// MARK: Internal | ||
|
||
let activity: Activity | ||
|
||
var body: some View { | ||
List { | ||
Section { | ||
HStack { | ||
HStack(alignment: .lastTextBaseline) { | ||
Image(uiImage: self.activity.details.iconImage) | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 120, height: 120) | ||
.clipShape(Circle()) | ||
|
||
VStack(alignment: .leading) { | ||
Text(self.activity.details.title) | ||
.font(.title) | ||
|
||
Text(self.activity.details.subtitle) | ||
.font(.title2) | ||
.foregroundColor(.secondary) | ||
|
||
Text(self.activity.details.description) | ||
} | ||
} | ||
|
||
Spacer() | ||
} | ||
} | ||
|
||
Section { | ||
DisclosureGroup("**Authors**") { | ||
ForEach(self.activity.authors, id: \.self) { author in | ||
let author = Authors.hmi(id: author)! | ||
HStack { | ||
Text(author.name) | ||
Button { | ||
self.selectedAuthor = author | ||
} label: { | ||
Image(systemName: "info.circle") | ||
} | ||
} | ||
} | ||
} | ||
.sheet(item: self.$selectedAuthor, onDismiss: { self.selectedAuthor = nil }, content: { author in | ||
VStack(alignment: .leading) { | ||
Text(author.name) | ||
.font(.headline) | ||
Text(author.description) | ||
} | ||
}) | ||
|
||
DisclosureGroup("**Skills**") { | ||
ForEach(self.activity.skills, id: \.self) { skill in | ||
let skill = Skills.skill(id: skill)! | ||
HStack { | ||
Text(skill.name) | ||
Button { | ||
self.selectedSkill = skill | ||
} label: { | ||
Image(systemName: "info.circle") | ||
} | ||
} | ||
} | ||
} | ||
.sheet(item: self.$selectedSkill, onDismiss: { self.selectedSkill = nil }, content: { skill in | ||
VStack(alignment: .leading) { | ||
Text(skill.name) | ||
.font(.headline) | ||
Text(skill.description) | ||
} | ||
}) | ||
|
||
DisclosureGroup("**HMI**") { | ||
ForEach(self.activity.hmi, id: \.self) { hmi in | ||
let hmi = HMI.hmi(id: hmi)! | ||
HStack { | ||
Text(hmi.name) | ||
Button { | ||
self.selectedHMI = hmi | ||
} label: { | ||
Image(systemName: "info.circle") | ||
} | ||
} | ||
} | ||
} | ||
.sheet(item: self.$selectedHMI, onDismiss: { self.selectedHMI = nil }, content: { hmi in | ||
VStack(alignment: .leading) { | ||
Text(hmi.name) | ||
.font(.headline) | ||
Text(hmi.description) | ||
} | ||
}) | ||
} | ||
|
||
Section { | ||
Markdown(self.activity.details.instructions) | ||
.markdownTheme(.gitHub) | ||
} | ||
} | ||
.toolbar { | ||
ToolbarItem { | ||
Button { | ||
print("Start activity") | ||
} label: { | ||
Image(systemName: "play.circle") | ||
Text("Start activity") | ||
} | ||
.buttonStyle(.borderedProminent) | ||
.tint(.lkGreen) | ||
} | ||
} | ||
} | ||
|
||
// MARK: Private | ||
|
||
@State private var selectedAuthor: Author? | ||
@State private var selectedSkill: Skill? | ||
@State private var selectedHMI: HMIDetails? | ||
} | ||
|
||
#Preview { | ||
NavigationStack { | ||
ActivityDetailsView(activity: Activity.mock) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Apps/LekaApp/Sources/_NEWCodeBase/Views/Activities/SampleActivityListView.swift
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,33 @@ | ||
// Leka - iOS Monorepo | ||
// Copyright APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import ContentKit | ||
import SwiftUI | ||
|
||
struct SampleActivityListView: View { | ||
let activities: [Activity] = ContentKit.listSampleActivities() ?? [] | ||
|
||
var body: some View { | ||
List { | ||
ForEach(self.activities) { activity in | ||
NavigationLink(destination: ActivityDetailsView(activity: activity)) { | ||
Image(uiImage: activity.details.iconImage) | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 44, height: 44) | ||
.clipShape(Circle()) | ||
|
||
Text(activity.details.title) | ||
} | ||
} | ||
} | ||
.navigationTitle("Sample Activities") | ||
} | ||
} | ||
|
||
#Preview { | ||
NavigationStack { | ||
SampleActivityListView() | ||
} | ||
} |
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
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
3 changes: 3 additions & 0 deletions
3
...les/ContentKit/Resources/Content/activities/icons/placeholder.activity.icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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