Commit Graph

5 Commits

Author SHA1 Message Date
Qun Cheng
4a0f261b4e
Add Card.filled and Card.outlined factory methods (#136229)
Fixes #119401

This PR is to:
* add `Card.filled` and `Card.outlined` factory methods so that we can use tokens for these two types of cards to generate default theme instead of providing hard-corded values in example.
* update card.2.dart example.
* add test file for card.2.dart example.
* fix some mismatch caused by editing the auto-generated defaults by hand in navigation_bar.dart and navigation_drawer.dart.
2023-11-01 23:29:49 +00:00
Taha Tesser
7cef966147
Fix NavigationDrawer selected item has wrong icon color (#129625)
fixes [NavigationDrawer selected item has wrong icon color [Material3 spec]](https://github.com/flutter/flutter/issues/129572)

### Description
This PR fixes a mistake in the `NavigationDrawer` defaults, where generated token value returns a `null`. 
This issue can be detected when you want to customize the selected icon color for `NavigationDrawerDestination` using a custom color scheme.

### Code sample

<details> 
<summary>expanded to view the code sample</summary> 

```dart
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      themeMode: ThemeMode.light,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue).copyWith(
          onSecondaryContainer: Colors.red,
        ),
        useMaterial3: true,
      ),
      home: const Example(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('NavigationDrawer Sample'),
      ),
      drawer: const NavigationDrawer(
        children: <Widget>[
          NavigationDrawerDestination(
            icon: Icon(Icons.favorite_outline_rounded),
            label: Text('Favorite'),
            selectedIcon: Icon(Icons.favorite_rounded),
          ),
          NavigationDrawerDestination(
            icon: Icon(Icons.favorite_outline_rounded),
            label: Text('Favorite'),
          ),
        ],
      ),
    );
  }
}
``` 
	
</details>

### Before
 
<img width="1053" alt="Screenshot 2023-06-27 at 13 24 38" src="https://github.com/flutter/flutter/assets/48603081/18c13a73-688f-4586-bb60-bddef45d173f">

### After

<img width="1053" alt="Screenshot 2023-06-27 at 13 24 25" src="https://github.com/flutter/flutter/assets/48603081/8a1427c6-517f-424a-b0bd-24bad7c5fbb0">
2023-06-30 08:58:14 +00:00
Pierre-Louis
66cda5917d
Improve defaults generation with logging, stats, and token validation (#128244)
## Description

This improves defaults generation with logging, stats, and token validation. 

This PR includes these changes:
* introduce `TokenLogger`, with a verbose mode
  * prints versions and tokens usage to the console
  * outputs `generated/used_tokens.csv`, a list of all used tokens, for use by Google
* find token files in `data` automatically
* hide tokens `Map`
  * tokens can be obtained using existing resolvers (e.g. `color`, `shape`), or directly through `getToken`.
  * tokens can be checked for existence with `tokenAvailable`
* remove version from template, since the tokens are aggregated and multiple versions are possible (as is the case currently), it does not make sense to attribute a single version
* improve documentation

## Related Issues
 - Fixes https://github.com/flutter/flutter/issues/122602

## Tests
 - Added tests for `TokenLogger`
 - Regenerated tokens, no-op except version removal

## Future work
A future PR should replace or remove the following invalid tokens usages

<img width="578" alt="image" src="https://github.com/flutter/flutter/assets/6655696/b6f9e5a7-523f-4f72-94f9-1b0bf4cc9f00">
2023-06-09 11:28:18 +00:00
Taha Tesser
d24a28b806
Cleanup M3 token templates for theme lookups (#122601)
Cleanup M3 token templates for theme lookups
2023-03-14 17:01:13 +00:00
hangyu
0e57147db1
nav drawer (#115668) 2022-11-18 15:10:05 -08:00