drawer_template.dart 1.56 KB
Newer Older
hangyu's avatar
hangyu committed
1 2 3 4 5 6 7 8 9 10 11 12
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'template.dart';

class DrawerTemplate extends TokenTemplate {
  const DrawerTemplate(super.blockName, super.fileName, super.tokens);

  @override
  String generate() => '''
class _${blockName}DefaultsM3 extends DrawerThemeData {
13
  _${blockName}DefaultsM3(this.context)
hangyu's avatar
hangyu committed
14 15 16
      : super(elevation: ${elevation("md.comp.navigation-drawer.modal.container")});

  final BuildContext context;
17
  late final TextDirection direction = Directionality.of(context);
hangyu's avatar
hangyu committed
18 19 20 21 22 23 24 25 26 27

  @override
  Color? get backgroundColor => ${componentColor("md.comp.navigation-drawer.container")};

  @override
  Color? get surfaceTintColor => ${colorOrTransparent("md.comp.navigation-drawer.container.surface-tint-layer.color")};

  @override
  Color? get shadowColor => ${colorOrTransparent("md.comp.navigation-drawer.container.shadow-color")};

28 29
  // There isn't currently a token for this value, but it is shown in the spec,
  // so hard coding here for now.
hangyu's avatar
hangyu committed
30
  @override
31 32 33 34
  ShapeBorder? get shape => RoundedRectangleBorder(
    borderRadius: const BorderRadiusDirectional.horizontal(
      end: Radius.circular(16.0),
    ).resolve(direction),
hangyu's avatar
hangyu committed
35 36
  );

37 38
  // There isn't currently a token for this value, but it is shown in the spec,
  // so hard coding here for now.
hangyu's avatar
hangyu committed
39
  @override
40 41 42 43
  ShapeBorder? get endShape => RoundedRectangleBorder(
    borderRadius: const BorderRadiusDirectional.horizontal(
      start: Radius.circular(16.0),
    ).resolve(direction),
hangyu's avatar
hangyu committed
44 45 46 47
  );
}
''';
}