Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/timetable feature grid2 #367

Merged
merged 29 commits into from
Aug 18, 2024
Merged

Conversation

charles-b-stb
Copy link
Contributor

@charles-b-stb charles-b-stb commented Aug 12, 2024

Issue

  • ??

Overview (Required)

  • Added very basic gridview to iOS timetable
  • Will need additional fixes before full release

Links

Screenshot (Optional if screenshot test is present or unrelated to UI)

Before After

Movie (Optional)

Before After
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-08-13.at.00.25.11.mp4

}.first
}

func getCellForRoom(room: RoomType, onTap: @escaping (TimetableItem) -> Void) -> TimetableGridCard {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the view code. Move this to the appropriate view definition file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the UI file. I still am using an extension because if the code in the loop gets too complicated iOS just fails to render the list.

If you have a better suggestion for this I am open for other ideas. 🙇

var body: some View {
let rooms = RoomType.allCases.filter {$0 != RoomType.roomIj}

ScrollView(.vertical) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ScrollView([.horizontal, .vertical])
is useful.

@charles-b-stb
Copy link
Contributor Author

@shin-usu Tested with the new TimetableRoom location and there are no problems.

@charles-b-stb
Copy link
Contributor Author

charles-b-stb commented Aug 13, 2024

New build fail due to movement of shape?

Error: value of type 'TimetableRoom' has no member 'shape'
timetableItem.room.shape

This built locally but I will investigate the error and fix it before moving forward

Copy link
Contributor

@shin-usu shin-usu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't confirm all code in this pull request, but I left some comments!
I will check the rest of the code later.

Comment on lines 1 to 6
//
// File.swift
//
//
// Created by CHARLES BOND on 2024/08/12.
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you delete file header?

//

import Foundation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe unnecessary line.

Suggested change

Comment on lines 51 to 57
if let url = URL(string: speaker.iconUrl) {
AsyncImage(url: url) {
$0.image?.resizable()
}
} else {
Circle().stroke(Color.gray)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, it would be fine following code. Sorry if I am wrong...

AsyncImage(url: URL(string: speaker.iconUrl)) {
    $0.image?.resizable()
} placeholder: {
    Color.gray
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this code from TImetableCard... maybe they could share this fix?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it can be shared!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image part was slightly wrong but I fixed it.

@charles-b-stb
Copy link
Contributor Author

Looks like a merge just right after my last pull broke it. I will look for a work-around

ForEach(rooms, id: \.self) { room in

timeBlock.getCellForRoom(room: room, onTap: { item in
store.send(.view(.timetableItemTapped))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TimetableItemWithFavorite instance should be passed to timetableItemTapped 🙏🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to backmerge for this to work, so I will fix that soon.

Comment on lines 66 to 68
VStack {
//Empty on purpose
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to instead it to EmptyView() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will try it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty view collapses. We need something that will hold the space open.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about following?

        Color.clear
            .frame(maxWidth: .infinity)
            .padding(12)
            .frame(width: 192, height: 153)
            .clipShape(RoundedRectangle(cornerRadius: 4))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct my understanding that sample data no longer used?
If so, I don't think this file name is appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample data is still used in previews. I can refactor this to break out data class items.

app-ios/Sources/TimetableFeature/TimetableListView.swift Outdated Show resolved Hide resolved
EdgeInsets(top: 2,leading: 7, bottom: 2, trailing: 7))
.border(highlight ? AssetColors.Custom.flamingo.swiftUIColor : AssetColors.Surface.onSurface.swiftUIColor)
.padding(-2)
func getTimetableRoom(type: RoomType) -> TimetableRoom {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more Swift-Like to implement this convert logic in extension.
Also, you can narrow the scope in which this function can be used.

extension RoomType {
    func toRoom() -> TimetableRoom {
        ...
    }
}

let type: RoomType = .roomI
let room = type.toRoom()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 241 to 242
jaTitle: "All",
enTitle: "All"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to KMP's implementation, It seems like room IJ's name is "Iguana and Jellyfish"👀
スクリーンショット 2024-08-14 1 10 49

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not an item for all rooms? From the UI it looked like some events fill the whole screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bigger question: Do we have any examples of Iguana and Jellyfish? It seems like a case we should test in grid mode.

@charles-b-stb
Copy link
Contributor Author

@shin-usu Responded to comments.

@charles-b-stb
Copy link
Contributor Author

also @ry-itto I responded to your comments.

.overlay(RoundedRectangle(cornerRadius: 4).stroke(timetableItem.room.roomTheme.primaryColor, lineWidth: 1))
}
} else {
Spacer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charles-b-stb
@ry-itto suggested the Color.clear.
Is there a reason you used Spacer?
I don't think Spacer is often used for this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shin-usu
I didn't see the Color.clear suggestion, sorry.

(This thread is getting very long)

Spacer holds the spot properly so it seemed like a valid use case. It seems more weird to me to use color here but if that is normal for iOS I can switch to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shin-usu @ry-itto Swapped for Color.

I think I have responded to all comments.

@shin-usu
Copy link
Contributor

No other places of concern other than ry-itto's comment.
Thanks for the correction😊
Please wait ry-itto's review.

@charles-b-stb
Copy link
Contributor Author

@ry-itto Fixed as recommended. Thank you

Copy link
Contributor

@MrSmart00 MrSmart00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a comment!
please check it🙏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This view isn't common component I think.
you should move to Timetable package please🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it, but it did require me to make one shared class between the card classes public (it was package before)

Copy link
Contributor

@MrSmart00 MrSmart00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX!
I left a comment!
check it please🙏

import class shared.TimetableItem

public struct TimetableGridCard: View {
let timetableItem: TimetableItem?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this property to be required?
maybe its more than smart and simple i think🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MrSmart00 Currently empty cells depend on this value being able to be null. I don't think I can make this not null-able without breaking empty cells.

Do you have an alternate suggestion for empty cells? 🙇

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charles-b-stb
I know you said situation.
I said means nil check should be out of the view.

you show the view or Color.clear with the property's nil check right?
but Color.clear is not TimetableGridCard view i think🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MrSmart00 I rewrote the code to move Clear outside of TimetableGridCard.

Copy link
Contributor

@MrSmart00 MrSmart00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX!!!
LGTM👍

@charles-b-stb charles-b-stb merged commit 20baf7c into main Aug 18, 2024
6 checks passed
@charles-b-stb charles-b-stb deleted the feature/timetable-feature-grid2 branch August 18, 2024 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants