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

added animated Header #1871

Merged
merged 16 commits into from
Feb 27, 2025
Merged

added animated Header #1871

merged 16 commits into from
Feb 27, 2025

Conversation

Umair-Manzoor-47
Copy link
Contributor

@Umair-Manzoor-47 Umair-Manzoor-47 commented Feb 14, 2025

ticket: #1863

 header:
    titleWidget: titleWIthMenu
    flexibleBackground: HeaderBackground
    styles:
      titleBarHeight: 72
      flexibleMaxHeight: 403
      flexibleMinHeight: 72
      backgroundColor: 0xFF0E154D
      scrollMode: pinned  // can be floating and Pinned (if using dropdown animation must stay pinned)
      animation:                // animation Map
        enabled: true         // flag for enabling/disabling
        duration: 300        // Animation lifecycle
        curve: easeIn        //  Curve for variety 

header.webm

@TheNoumanDev TheNoumanDev linked an issue Feb 14, 2025 that may be closed by this pull request
scrollableView: true,
showNavigationIcon: pageModel.runtimeStyles?['showNavigationIcon'],
);
// if (appBar is SliverAppBar) {
Copy link
Member

Choose a reason for hiding this comment

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

Why we are commenting out this condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there was already a check in _buildAppBar function
but it's importance came up later so will be adding it back

@@ -387,8 +435,11 @@ class PageState extends State<Page>
flexibleSpace: wrapsInFlexible(backgroundWidget),
expandedHeight: flexibleMaxHeight,
collapsedHeight: flexibleMinHeight,
floating: floating ?? false,
Copy link
Member

Choose a reason for hiding this comment

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

these values will never be null, as while setting you are already providing fallback value to it as bool? floating = Utils.getBool(evaluatedHeader?['floating'], fallback: false);, same goes for other values.

void performLayout() {
final double scrollOffset = constraints.scrollOffset;
final double maxExtent = height;
bool repaint = false;
Copy link
Member

Choose a reason for hiding this comment

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

this value is never used, why we are declaring 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.

Removing it as well.

@Umair-Manzoor-47
Copy link
Contributor Author

added the requested changes @TheNoumanDev

@sharjeelyunus
Copy link
Member

sharjeelyunus commented Feb 18, 2025

@Umair-Manzoor-47 can we hide/unhide the title widget as well? see the attached video in this ticket: #1863 initial state is no header, and when user scrolls down, the header with floating widget appears.
Can you replicate the design in the ticket, and add video here

@Umair-Manzoor-47
Copy link
Contributor Author

Sure @sharjeelyunus here is without titleWidget or title
Schema is

  header:
    subtitleWidget:
      Row:
        styles:
          height: 100
          padding: 0
          gap: 3
          crossAxis: center
          mainAxis: center
          backgroundColor: blue
        children:
          - Button:
              label: Menu

          - Button:
              label: Shop

          - Button:

              label: Cart
          - Button:
              label: Order

    styles:

      backgroundColor: White
      shadowColor: white
      titleBarHeight: 50
      animation: true
      subtitleHeightOffSet: 100

2025-02-19.22-33-57.mp4

@kmahmood74
Copy link
Collaborator

kmahmood74 commented Feb 19, 2025 via email

@Umair-Manzoor-47
Copy link
Contributor Author

Umair-Manzoor-47 commented Feb 20, 2025

there's already title and titleWidget
There are two options.
1. Either I can include a different widget (Subtitle Widget) that drops down as user scrolls. Independent of title or TitleWidget
2. Make the whole Header Dropdown
@kmahmood74 @TheNoumanDev

@kmahmood74
Copy link
Collaborator

kmahmood74 commented Feb 20, 2025 via email

Comment on lines 362 to 367
bool? pinned = Utils.getBool(evaluatedHeader?['pinned'], fallback: false);
bool? snapped = Utils.getBool(evaluatedHeader?['snapped'], fallback: false);
bool? floating =
Utils.getBool(evaluatedHeader?['floating'], fallback: false);
appBarBehaviour behaviour =
Utils.getEnum<appBarBehaviour>(evaluatedHeader?['scrollMode'], appBarBehaviour.values);
Copy link
Member

Choose a reason for hiding this comment

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

why do we have pinned, snapped, and floating properties here? aren't using scrollMode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done with refactoring

Copy link
Member

@TheNoumanDev TheNoumanDev left a comment

Choose a reason for hiding this comment

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

LGTM, before merging the PR, please also create Docs and Schema PR.

@Umair-Manzoor-47 Umair-Manzoor-47 merged commit c3a9950 into main Feb 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Animations for header (app bar)
4 participants