Material-components-ios: [BottomSheet] When styled with rounded corners, the rounded corners go square when dragging

Created on 29 Oct 2019  路  2Comments  路  Source: material-components/material-components-ios

Reproduction steps

Set up the component like this:

let controller = BlankViewController()
let bottomSheet = MDCBottomSheetController(contentViewController: controller)

let shapeScheme = MDCShapeScheme()
shapeScheme.largeComponentShape = MDCShapeCategory(cornersWith: .rounded, andSize: 8)

MDCBottomSheetControllerShapeThemer.applyShapeScheme(shapeScheme, to: bottomSheet)
present(bottomSheet, animated: true, completion: nil)

Where BlankViewController is just a completely empty white view controller for testing.

Expected behavior

  • When dragging the component up and down, the 8dp rounded corners should remain

Actual behavior

  • Instead when dragging up and down the corners revert to being squared off. As soon as you let go they go back to being rounded.

Screenshots:

  1. At rest:
    Screen_Shot_2019-10-29_at_4_49_48_pm
  2. On drag:
    Screen_Shot_2019-10-29_at_4_50_02_pm

Platform

  • Device: iOS Simulator
  • OS: iOS 13.1

Internal data

[BottomSheet] Bug

Most helpful comment

@rustyshelf, to complete your solution, you can only round the top corners if you want:

let shapeGenerator = MDCRectangleShapeGenerator()

let cornerTreatment = MDCRoundedCornerTreatment(radius: 8)
shapeGenerator.topLeftCorner = cornerTreatment
shapeGenerator.topRightCorner = cornerTreatment

bottomSheet.setShapeGenerator(shapeGenerator, for: .preferred)
bottomSheet.setShapeGenerator(shapeGenerator, for: .extended)
bottomSheet.setShapeGenerator(shapeGenerator, for: .closed)

All 2 comments

It seems that if the rounded corners are added as a Shape Generator instead of using the shape styling library then it works correctly:

let shapeGenerator = MDCCurvedRectShapeGenerator(cornerSize: CGSize(width: 8, height: 8))
bottomSheet.setShapeGenerator(shapeGenerator, for: .preferred)
bottomSheet.setShapeGenerator(shapeGenerator, for: .extended)
bottomSheet.setShapeGenerator(shapeGenerator, for: .closed)

Instead of

let shapeScheme = MDCShapeScheme()
shapeScheme.largeComponentShape = MDCShapeCategory(cornersWith: .rounded, andSize: 8)
MDCBottomSheetControllerShapeThemer.applyShapeScheme(shapeScheme, to: bottomSheet)

@rustyshelf, to complete your solution, you can only round the top corners if you want:

let shapeGenerator = MDCRectangleShapeGenerator()

let cornerTreatment = MDCRoundedCornerTreatment(radius: 8)
shapeGenerator.topLeftCorner = cornerTreatment
shapeGenerator.topRightCorner = cornerTreatment

bottomSheet.setShapeGenerator(shapeGenerator, for: .preferred)
bottomSheet.setShapeGenerator(shapeGenerator, for: .extended)
bottomSheet.setShapeGenerator(shapeGenerator, for: .closed)
Was this page helpful?
0 / 5 - 0 ratings