Skip to content

Conversation

@TahaTesser
Copy link
Member

fixes #105594

minimal code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key, this.dark = false, this.useMaterial3 = true});

  final bool dark;
  final bool useMaterial3;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      themeMode: dark ? ThemeMode.dark : ThemeMode.light,
      theme: ThemeData(
        useMaterial3: useMaterial3,
        brightness: Brightness.light,
        colorSchemeSeed: const Color(0xff6750a4),
      ),
      darkTheme: ThemeData(
        useMaterial3: useMaterial3,
        brightness: Brightness.dark,
        colorSchemeSeed: const Color(0xff6750a4),
      ),
      home: const MaterialBannerExample(),
    );
  }
}

class MaterialBannerExample extends StatelessWidget {
  const MaterialBannerExample({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('MaterialBanner Example'),
      ),
      body: MaterialBanner(
        content: const Text('Hello, I am a Material Banner'),
        leading: const Icon(Icons.agriculture_outlined),
        actions: <Widget>[
          TextButton(
            onPressed: () {},
            child: const Text('OPEN'),
          ),
          TextButton(
            onPressed: () {},
            child: const Text('DISMISS'),
          ),
        ],
      ),
    );
  }
}

Screenshot 2022-06-14 at 16 34 03

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Jun 14, 2022
@TahaTesser

This comment was marked as resolved.

@TahaTesser

This comment was marked as resolved.

@guidezpl

This comment was marked as resolved.

@TahaTesser TahaTesser requested a review from darrenaustin June 16, 2022 10:34
@TahaTesser TahaTesser force-pushed the m3_banner branch 2 times, most recently from d96ae2a to c3055c7 Compare July 18, 2022 08:28
@TahaTesser
Copy link
Member Author

TahaTesser commented Jul 18, 2022

Just resolved template conflicts.

@HansMuller HansMuller requested a review from hannah-hyj August 1, 2022 17:42
Copy link
Member

Choose a reason for hiding this comment

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

I see there are more properties (like actions, containerHeight, divider) in the token file. Should we add them in themeData too?

Copy link
Member Author

@TahaTesser TahaTesser Aug 26, 2022

Choose a reason for hiding this comment

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

Apologies for the delay.

actions parameter takes a list of widgets so the styling depends on the widget provided.

containerHeight aka min height isn't customizable currently, there are container height tokens for desktop and mobile. I would prefer to work in a separate PR after Banner is available on https://m3.material.io/.

Added divider color and other existing missing properties tests.

@TahaTesser TahaTesser force-pushed the m3_banner branch 2 times, most recently from f0c16eb to 529436d Compare August 26, 2022 14:49
Copy link
Contributor

@bleroux bleroux left a comment

Choose a reason for hiding this comment

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

LGTM with small nit

@TahaTesser TahaTesser requested review from hannah-hyj and removed request for darrenaustin August 26, 2022 15:38
Copy link
Member

@hannah-hyj hannah-hyj left a comment

Choose a reason for hiding this comment

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

LGTM

@TahaTesser TahaTesser added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 5, 2022
@auto-submit auto-submit bot merged commit d8fdb83 into flutter:master Sep 5, 2022
@TahaTesser TahaTesser deleted the m3_banner branch September 5, 2022 09:00
Color? get backgroundColor => _theme.colorScheme.surface;

@override
Color? get dividerColor => Theme.of(context).colorScheme.surfaceVariant;
Copy link
Member

Choose a reason for hiding this comment

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

This broke golden tests for flutter gallery, is this the correct value?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, based on token

"md.comp.banner.divider.color": "surfaceVariant",

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps the golden test is broken this color is added to the M2 template in this PR

Which uses Theme.dividerColor

?? (context != null ? (DividerTheme.of(context).color ?? Theme.of(context).dividerColor) : null);

Copy link
Member Author

Choose a reason for hiding this comment

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

I can revert this PR or remove the divider color from the M2 template.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, thanks. Since this is not breaking per the breaking change policy, and is effectively a fix so let's hold off unless there's a need to revert due to Google-internal usages.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the update!

Copy link
Member

Choose a reason for hiding this comment

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

@TahaTesser Actually the "banner.json" token file is only for M3. I think you should remove the divider color from the M2 template.

Copy link
Member

Choose a reason for hiding this comment

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

@TahaTesser Hi Taha, We are reverting this PR in #111288 because it caused some scuba breakages to google3. Please create another PR for this, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you @Hangyujin! My bad I should have been careful with the M2 template.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Sep 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Sep 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Sep 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 5, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 6, 2022
stuartmorgan-g pushed a commit to flutter/plugins that referenced this pull request Sep 6, 2022
* 5bb612c Roll Flutter Engine from 14eb83a7d0bd to a8e97892ce25 (1 revision) (flutter/flutter#110938)

* 798ce22 Roll Flutter Engine from a8e97892ce25 to 0a2f56cd025f (1 revision) (flutter/flutter#110940)

* 5de91d9 Roll Flutter Engine from 0a2f56cd025f to b040ed90175b (1 revision) (flutter/flutter#110954)

* 202f577 Roll Flutter Engine from b040ed90175b to b94120dfe9c6 (1 revision) (flutter/flutter#110960)

* d8fdb83 Update `MaterialBanner` to support Material 3 (flutter/flutter#105957)

* fbba194 Migrate `ListTile` disabled icon color to Material 3 (flutter/flutter#102078)

* f625359 Roll Flutter Engine from b94120dfe9c6 to 5a2861e499d2 (1 revision) (flutter/flutter#110972)

* eb154d5 Roll Flutter Engine from 5a2861e499d2 to 3ff25eb9081c (1 revision) (flutter/flutter#110974)

* 0144110 Roll Flutter Engine from 3ff25eb9081c to 47c281f218db (1 revision) (flutter/flutter#110983)

* b166390 Roll Flutter Engine from 47c281f218db to 25642a45a55e (1 revision) (flutter/flutter#110991)

* bce9163 Roll Flutter Engine from 25642a45a55e to 7b3710878503 (1 revision) (flutter/flutter#110992)

* 8cddac7 Roll Flutter Engine from 7b3710878503 to 3c0898c0dfed (1 revision) (flutter/flutter#110993)

* 96345a4 Roll Flutter Engine from 3c0898c0dfed to ddc5bb330254 (1 revision) (flutter/flutter#110999)

* 723b82e Feat: dSYM debug info for iOS & macOS builds (flutter/flutter#101586)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 6, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 6, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 6, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 6, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 7, 2022
Color? get dividerColor => Theme.of(context).colorScheme.surfaceVariant;

@override
TextStyle? get contentTextStyle => _theme.textTheme.bodyText2;
Copy link
Member

Choose a reason for hiding this comment

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

I think it should also be "theme.textTheme.bodyMedium" in M2

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I was gonna make this since it just points to bodyMedium anyways.

CaseyHillers added a commit that referenced this pull request Sep 9, 2022
adam-harwood pushed a commit to adam-harwood/flutter_plugins that referenced this pull request Nov 3, 2022
* 5bb612c Roll Flutter Engine from 14eb83a7d0bd to a8e97892ce25 (1 revision) (flutter/flutter#110938)

* 798ce22 Roll Flutter Engine from a8e97892ce25 to 0a2f56cd025f (1 revision) (flutter/flutter#110940)

* 5de91d9 Roll Flutter Engine from 0a2f56cd025f to b040ed90175b (1 revision) (flutter/flutter#110954)

* 202f577 Roll Flutter Engine from b040ed90175b to b94120dfe9c6 (1 revision) (flutter/flutter#110960)

* d8fdb83 Update `MaterialBanner` to support Material 3 (flutter/flutter#105957)

* fbba194 Migrate `ListTile` disabled icon color to Material 3 (flutter/flutter#102078)

* f625359 Roll Flutter Engine from b94120dfe9c6 to 5a2861e499d2 (1 revision) (flutter/flutter#110972)

* eb154d5 Roll Flutter Engine from 5a2861e499d2 to 3ff25eb9081c (1 revision) (flutter/flutter#110974)

* 0144110 Roll Flutter Engine from 3ff25eb9081c to 47c281f218db (1 revision) (flutter/flutter#110983)

* b166390 Roll Flutter Engine from 47c281f218db to 25642a45a55e (1 revision) (flutter/flutter#110991)

* bce9163 Roll Flutter Engine from 25642a45a55e to 7b3710878503 (1 revision) (flutter/flutter#110992)

* 8cddac7 Roll Flutter Engine from 7b3710878503 to 3c0898c0dfed (1 revision) (flutter/flutter#110993)

* 96345a4 Roll Flutter Engine from 3c0898c0dfed to ddc5bb330254 (1 revision) (flutter/flutter#110999)

* 723b82e Feat: dSYM debug info for iOS & macOS builds (flutter/flutter#101586)
mauricioluz pushed a commit to mauricioluz/plugins that referenced this pull request Jan 26, 2023
* 5bb612c Roll Flutter Engine from 14eb83a7d0bd to a8e97892ce25 (1 revision) (flutter/flutter#110938)

* 798ce22 Roll Flutter Engine from a8e97892ce25 to 0a2f56cd025f (1 revision) (flutter/flutter#110940)

* 5de91d9 Roll Flutter Engine from 0a2f56cd025f to b040ed90175b (1 revision) (flutter/flutter#110954)

* 202f577 Roll Flutter Engine from b040ed90175b to b94120dfe9c6 (1 revision) (flutter/flutter#110960)

* d8fdb83 Update `MaterialBanner` to support Material 3 (flutter/flutter#105957)

* fbba194 Migrate `ListTile` disabled icon color to Material 3 (flutter/flutter#102078)

* f625359 Roll Flutter Engine from b94120dfe9c6 to 5a2861e499d2 (1 revision) (flutter/flutter#110972)

* eb154d5 Roll Flutter Engine from 5a2861e499d2 to 3ff25eb9081c (1 revision) (flutter/flutter#110974)

* 0144110 Roll Flutter Engine from 3ff25eb9081c to 47c281f218db (1 revision) (flutter/flutter#110983)

* b166390 Roll Flutter Engine from 47c281f218db to 25642a45a55e (1 revision) (flutter/flutter#110991)

* bce9163 Roll Flutter Engine from 25642a45a55e to 7b3710878503 (1 revision) (flutter/flutter#110992)

* 8cddac7 Roll Flutter Engine from 7b3710878503 to 3c0898c0dfed (1 revision) (flutter/flutter#110993)

* 96345a4 Roll Flutter Engine from 3c0898c0dfed to ddc5bb330254 (1 revision) (flutter/flutter#110999)

* 723b82e Feat: dSYM debug info for iOS & macOS builds (flutter/flutter#101586)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App c: contributor-productivity Team-specific productivity, code health, technical debt. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update MaterialBanner to support Material 3

4 participants