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

Adding SwiftUI implementation of Menu List #334

Merged
merged 19 commits into from
Jan 5, 2021

Conversation

sophialee0416
Copy link
Contributor

@sophialee0416 sophialee0416 commented Dec 9, 2020

Platforms Impacted

  • iOS
  • macOS

Description of changes

This PR contains the first draft of List (counterpart of UITableView from UIKit), created in SwiftUI. Currently, it supports leading icons, title, and subtitle properties.

Verification

  • The TableViewCellVnext Demo Controller uses the same sample data as the non-vNext version. All issues mentioned in PR#330 also pertain to this component.
Simulator Screen Shot - iPhone 12 Pro - 2020-12-30 at 15 53 26 Simulator Screen Shot - iPhone 12 - 2020-12-21 at 17 54 03

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
Microsoft Reviewers: Open in CodeFlow
Microsoft Reviewers: Open in CodeFlow

@sophialee0416 sophialee0416 requested review from a team as code owners December 9, 2020 10:12
@sophialee0416 sophialee0416 added the vnext-prototype Changes meant to be merged to the vnext-prototype branch. label Dec 9, 2020
@harrieshin
Copy link
Contributor

looking at the screenshot this doesn't seem right.
-the singleline cell hight seeems incorrect.

  • the title isn't veritcally centered.
  • separator should be indented and more aligned with text
  • double cell height seem not right too?

Copy link
Contributor

@rdeassis rdeassis left a comment

Choose a reason for hiding this comment

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

This file should not be part of the change:
tools/sgen/Pods/Target Support Files/Pods-sgen/Pods-sgen-frameworks.sh

ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
padding: $Spacing.medium
textFont: $Typography.body
subtitleFont: $Typography.subheadline
iconColor: [ iconOnly: $Colors.Foreground.neutral3, withLabel: $Colors.Foreground.neutral4, disclosure: $Colors.Foreground.neutral4 ]
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 the variations in the figma should be appearance proxies that extend MSFListTokens.
Once we get the state colors like pressed, hover, etc... this will be a matrix of styles vs states for this color.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
tools/sgen/input/FluentUIStyle.yml Outdated Show resolved Hide resolved
tools/sgen/input/FluentUIStyle.yml Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
}

private func updateLayout(subtitle: String?) -> MSFListCellVnextLayoutType {
if subtitle != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we covering the three line scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of now, no. We do not have the tokens defined yet, but @Victa should be following up with them later when we need them

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! I think it's worth creating a GitHub issue to track that work item.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@objc(MSFListVnextCellData)
public class MSFListVnextCellData: NSObject, ObservableObject, Identifiable {
public var id = UUID()
@objc @Published public var leadingIcon: UIImage?
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll soon need to add a view as an option to the image (Avatar cell scenario).
Can you create a GitHub issue to track that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Show resolved Hide resolved
public var id = UUID()
@objc @Published public var cells: [MSFListVnextCellData] = []
@objc @Published public var title: String?
@objc @Published public var layoutType: MSFListCellVnextLayoutType = .oneLine
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be nicer to allow the calling code to specify the layout type per cell (in the MSFListVnextCellData)?
We can discuss this after your first merge (it's worth a GitHub issue to track as well).

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 wanted to consider both cell design + consistency... should we allow sections to contain cells of different heights or lead users into sticking to uniformity? I agree we should continue this in a discussion, I will create an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

case twoLines
case threeLines

var height: CGFloat {
Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing that can be changed later (GitHub issue):
These values should be tokenized in the YAML file.
Something like:

AP_MSFListTokens:
  cellHeight: [ oneLine: 48, twoLines: 64, threeLines: 84 ]
  ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Since you added the tokens for these, the snippet below should be removed and you should use the tokenized value instead:

var height: CGFloat {
     switch self {
     case .oneLine:
         return 48
     case .twoLines:
         return 64
     case .threeLines:
         return 84
     }
 }

}
}

extension MSFListView {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the benefit of having these types in the MSFListView extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was for organization purposes, but I'm thinking of splitting the file (which will be tracked in a GH issue)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@rdeassis rdeassis left a comment

Choose a reason for hiding this comment

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

Just some last nit comments, but overall looking good! :)

Also, can you remove Pods-sgen-frameworks.sh from the PR?
This is just about the execution permission that won't make any difference if checked in.

ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
let demoControllerView: UIView = self.view
demoControllerView.addSubview(listView)

NSLayoutConstraint.activate([demoControllerView.safeAreaLayoutGuide.topAnchor.constraint(equalTo: listView.topAnchor),
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are using a custom constraint it would a good idea to not inherit from DemoController and just use UIViewController

@harrieshin harrieshin added this to To do in vnext controls Jan 4, 2021
vnext controls automation moved this from To do to Reviewer approved Jan 5, 2021
ios/FluentUI/Table View/ListVnext.swift Outdated Show resolved Hide resolved
@rdeassis
Copy link
Contributor

rdeassis commented Jan 5, 2021

Thanks for addressing all the comments! :)

@sophialee0416 sophialee0416 merged commit eef904b into vnext-prototype Jan 5, 2021
vnext controls automation moved this from Reviewer approved to Done Jan 5, 2021
@sophialee0416 sophialee0416 deleted the sople/listVnext branch January 5, 2021 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vnext-prototype Changes meant to be merged to the vnext-prototype branch.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants