• stkhapugin@chromium.org's avatar
    Add new constraint utils. · c14074ef
    stkhapugin@chromium.org authored
    In many situations two views are constrained by three sides, and:
    a) the fourth side is constraint to another view
    b) the fourth side is constraint with an offset
    
    This implements a new helper:
    void AddSameConstraintsToSidesWithInsets(
        id<LayoutGuideProvider> innerView,
        id<LayoutGuideProvider> outerView,
        ios::LayoutSides sides,
        ios::ChromeDirectionalEdgeInsets insets);
    
    This should allow writing things like:
    
    AddSameConstraintsToSidesWithInsets(view1, view2,
      LayoutSides::kTop|LayoutSides::kLeading,
      ChromeDirectionalEdgeInsets{10, 5, 8, 8});
    
    and a simplified version with no insets:
    
    AddSameConstraintsToSides(view1, view2,
      LayoutSides::kTop|LayoutSides::kLeading);
    
    These helpers should reduce boilerplate in layout code.
    
    Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
    Change-Id: If1ef5427dde1fe7e098f212b6917d9566d1df0e6
    Reviewed-on: https://chromium-review.googlesource.com/859789
    Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
    Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
    Reviewed-by: default avatarMark Cogan <marq@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#537328}
    c14074ef
constraints_ui_util.mm 7.59 KB