Skip to content

Commit

Permalink
[iOS] Implement Timetable essentials UI (#303)
Browse files Browse the repository at this point in the history
* implement essentials

* use common component for section header

* add strings

* add detail summary component

* add detail header component

* add detail content component

* add timetable item property

* call contents from detail screen

* use 4 spacing, common protocol

* fix parameter name

* format

---------

Co-authored-by: swimmy-reo <[email protected]>
Co-authored-by: Swimmy <[email protected]>
  • Loading branch information
3 people authored Aug 3, 2023
1 parent 95c37d6 commit c7bd153
Show file tree
Hide file tree
Showing 78 changed files with 1,366 additions and 112 deletions.
27 changes: 27 additions & 0 deletions app-ios/Modules/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var package = Package(
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "0.1.0"),
.package(url: "https://github.com/realm/SwiftLint", from: "0.52.2"),
.package(url: "https://github.com/SwiftGen/SwiftGenPlugin", from: "6.6.0"),
],
targets: [
.target(
Expand All @@ -33,6 +34,17 @@ var package = Package(
]
),

.target(
name: "Assets",
resources: [
.process("Resources"),
.process("swiftgen.yml"),
],
plugins: [
.plugin(name: "SwiftGenPlugin", package: "SwiftGenPlugin"),
]
),

.target(
name: "FloorMap",
dependencies: [
Expand Down Expand Up @@ -75,8 +87,10 @@ var package = Package(
.target(
name: "Timetable",
dependencies: [
"Assets",
"shared",
"Model",
"Theme",
]
),
.testTarget(
Expand All @@ -90,9 +104,11 @@ var package = Package(
name: "Navigation",
dependencies: [
"About",
"Assets",
"FloorMap",
"Session",
"Stamps",
"Theme",
"Timetable",
]
),
Expand All @@ -104,6 +120,17 @@ var package = Package(
]
),

.target(
name: "Theme",
resources: [
.process("Resources"),
.process("swiftgen.yml"),
],
plugins: [
.plugin(name: "SwiftGenPlugin", package: "SwiftGenPlugin"),
]
),

.binaryTarget(
name: "shared",
path: "../../app-ios-shared/build/XCFrameworks/release/shared.xcframework"
Expand Down
28 changes: 28 additions & 0 deletions app-ios/Modules/Sources/Assets/Bundle.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Workaround: https://developer.apple.com/forums/thread/664295
import Foundation

private class CurrentBundleFinder {}

public extension Bundle {
static var myModule: Bundle = {
/* The name of your local package, prepended by "LocalPackages_" */
let bundleName = "Modules_Assets"
let candidates = [
/* Bundle should be present here when the package is linked into an App. */
Bundle.main.resourceURL,
/* Bundle should be present here when the package is linked into a framework. */
Bundle(for: CurrentBundleFinder.self).resourceURL,
/* For command-line tools. */
Bundle.main.bundleURL,
/* Bundle should be present here when running previews from a different package (this is the path to "…/Debug-iphonesimulator/"). */
Bundle(for: CurrentBundleFinder.self).resourceURL?.deletingLastPathComponent().deletingLastPathComponent(),
]
for candidate in candidates {
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
return bundle
}
}
fatalError("unable to find bundle named \(bundleName)")
}()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "badge.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "bookmark.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "bookmark.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "leading-icon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "error.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "trailing-icon 3.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "info.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "map.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "trailing-icon 1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "timetable.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "02.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
14 changes: 14 additions & 0 deletions app-ios/Modules/Sources/Assets/swiftgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
input_dir: Resources/
output_dir: ${DERIVED_SOURCES_DIR}/

xcassets:
inputs:
- Icons.xcassets
- Images.xcassets
outputs:
templateName: swift5
output: Assets.generated.swift
params:
enumName: Assets
publicAccess: true
bundle: Bundle.myModule
9 changes: 9 additions & 0 deletions app-ios/Modules/Sources/Model/Extension/KotlinArray.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import shared

public extension Array where Element: NSObject {
static func fromKotlinArray(_ kotlinArray: KotlinArray<Element>) -> Self {
(0..<kotlinArray.size).compactMap { index in
kotlinArray.get(index: index)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ extension Kotlinx_datetimeInstant {
return Date(timeIntervalSince1970: TimeInterval(toEpochMilliseconds()))
}
}

16 changes: 15 additions & 1 deletion app-ios/Modules/Sources/Model/LoadingState.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
public enum LoadingState<State> {
public enum LoadingState<State: Equatable>: Equatable {
case initial
case loading
case loaded(State)
case failed(Error)

public static func == (lhs: LoadingState<State>, rhs: LoadingState<State>) -> Bool {
switch (lhs, rhs) {
case (.initial, .initial),
(.loading, .loading):
return true
case (.loaded(let lState), .loaded(let rState)):
return lState == rState
case (.failed(let lError), .failed(let rError)):
return lError.localizedDescription == rError.localizedDescription
default:
return false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct TimetableTimeGroupItems: Identifiable, Equatable, Hashable {
}

public var id: String {
items.first?.timetableItem.id.value ?? UUID().uuidString
UUID().uuidString
}

public var startsAt: Date
Expand Down
1 change: 1 addition & 0 deletions app-ios/Modules/Sources/Model/ViewModelState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public protocol ViewModelState: Equatable {}
31 changes: 27 additions & 4 deletions app-ios/Modules/Sources/Navigation/RootView.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import About
import Assets
import FloorMap
import Session
import Stamps
import SwiftUI
import Theme
import Timetable

enum Tab {
Expand All @@ -26,24 +28,45 @@ public struct RootView: View {
)
.tag(Tab.timeline)
.tabItem {
Label("Timeline", systemImage: "circle")
Label {
Text("Timetable")
} icon: {
Assets.Icons.timetable.swiftUIImage
.renderingMode(.template)
}
}
FloorMapView()
.tag(Tab.floorMap)
.tabItem {
Label("FloorMap", systemImage: "circle")
Label {
Text("FloorMap")
} icon: {
Assets.Icons.map.swiftUIImage
.renderingMode(.template)
}
}
StampsView()
.tag(Tab.stamps)
.tabItem {
Label("Stamps", systemImage: "circle")
Label {
Text("Stamps")
} icon: {
Assets.Icons.badge.swiftUIImage
.renderingMode(.template)
}
}
AboutView()
.tag(Tab.about)
.tabItem {
Label("About", systemImage: "circle")
Label {
Text("About")
} icon: {
Assets.Icons.info.swiftUIImage
.renderingMode(.template)
}
}
}
.tint(AssetColors.Secondary.onSecondaryContainer.swiftUIColor)
}
}

Expand Down
Loading

0 comments on commit c7bd153

Please sign in to comment.