Skip to content

Commit

Permalink
🔀 Merge branch 'ladislas/feature/lekaapp-list-sample-activities'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Feb 20, 2024
2 parents 0d41cb3 + e96c845 commit 7784625
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Apps/LekaApp/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ let project = Project.app(
.project(target: "DesignKit", path: Path("../../Modules/DesignKit")),
.project(target: "RobotKit", path: Path("../../Modules/RobotKit")),
.project(target: "AccountKit", path: Path("../../Modules/AccountKit")),
.project(target: "ContentKit", path: Path("../../Modules/ContentKit")),
.external(name: "Yams"),
.external(name: "MarkdownUI"),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension Navigation {
case activities
case remotes
case stories
case sampleActivities
case carereceivers

// MARK: Internal
Expand Down
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)
}
}
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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ extension MainView {
self.title = String(l10n.MainView.Sidebar.CategoryLabel.stories.characters)
self.systemImage = "book"

case .sampleActivities:
self.title = "Sample activites"
self.systemImage = "testtube.2"

case .carereceivers:
self.title = String(l10n.MainView.Sidebar.CategoryLabel.carereceivers.characters)
self.systemImage = "person.circle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct MainView: View {
CategoryLabel(category: .activities)
CategoryLabel(category: .remotes)
CategoryLabel(category: .stories)
CategoryLabel(category: .sampleActivities)
}

Section(String(l10n.MainView.Sidebar.sectionUsers.characters)) {
Expand Down Expand Up @@ -106,6 +107,9 @@ struct MainView: View {
.font(.largeTitle)
.bold()

case .sampleActivities:
SampleActivityListView()

case .carereceivers:
CarereceiverPicker()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct SelectedActivityInstructionsViewDeprecated: View {
.fill(DesignKitAsset.Colors.lekaLightGray.swiftUIColor)
.edgesIgnoringSafeArea(.bottom)
.overlay { InstructionsViewDeprecated() }
.overlay { GoButton() }
.overlay { GoButtonDeprecated() }
}
}
.preferredColorScheme(.light)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import DesignKit
import SwiftUI

struct GoButton: View {
struct GoButtonDeprecated: View {
// MARK: Internal

@EnvironmentObject var company: CompanyViewModelDeprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct CurriculumDetailsViewDeprecated: View {
.edgesIgnoringSafeArea(.bottom)
.overlay { InstructionsViewDeprecated() }
.overlay {
GoButton()
GoButtonDeprecated()
.disabled(self.goButtonIsDisabled())
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions Modules/ContentKit/Sources/Activity/Activity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,8 @@ public extension Activity {
public let instructions: String

public var iconImage: UIImage {
guard let image = UIImage(named: "\(self.icon).activity.icon.png", in: .module, with: nil) else {
log.error("No image found for icon \(self.icon)")
fatalError("💥 No image found for icon \(self.icon)")
}

return image
UIImage(named: "\(self.icon).activity.icon.png", in: .module, with: nil)
?? UIImage(named: "placeholder.activity.icon.png", in: .module, with: nil)!
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Modules/DesignKit/Sources/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ public extension Color {
static let lkBackground: Color = .init(uiColor: .systemGray6)
static let lkStroke: Color = .init(uiColor: .systemGray)
static let lkNavigationTitle: Color = DesignKitAsset.Colors.lekaDarkBlue.swiftUIColor
static let lkGreen: Color = .init(light: UIColor(displayP3Red: 175 / 255, green: 206 / 255, blue: 54 / 255, alpha: 1),
dark: UIColor(displayP3Red: 175 / 255, green: 206 / 255, blue: 54 / 255, alpha: 1))
}

public extension ShapeStyle where Self == Color {
static var lkBackground: Color { .lkBackground }
static var lkStroke: Color { .lkStroke }
static var lkNavigationTitle: Color { .lkNavigationTitle }
static var lkGreen: Color { .lkGreen }
}
2 changes: 1 addition & 1 deletion Tuist/ProjectDescriptionHelpers/Project+App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public extension Project {
static func app(
name: String,
version: String = "1.0.0",
deploymentTargets: DeploymentTargets = .iOS("16.0"),
deploymentTargets: DeploymentTargets = .iOS("16.6"),
destinations: Destinations = [.iPad, .macWithiPadDesign],
infoPlist: [String: Plist.Value] = [:],
settings: SettingsDictionary = [:],
Expand Down

0 comments on commit 7784625

Please sign in to comment.