mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Instead of MaterialComponent being a base class, components that want material behavior simply create a MaterialComponent during their render function. This approach gives the component more flexibility as to its structure and gives MaterialComponent more flexibility has to how the components it generates are related to the existing children. Also, I've improved some of the event delegation code. There's no reason to attach event handlers to the root component you emit during |render| because the framework already delegates events from your root component to you. R=rafaelw@chromium.org Review URL: https://codereview.chromium.org/983903003
44 lines
1.0 KiB
Dart
44 lines
1.0 KiB
Dart
// Copyright 2015 The Chromium 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 '../fn.dart';
|
|
import 'button_base.dart';
|
|
import 'material.dart';
|
|
|
|
class Button extends ButtonBase {
|
|
static final Style _style = new Style('''
|
|
transform: translateX(0);
|
|
display: inline-flex;
|
|
border-radius: 4px;
|
|
justify-content: center;
|
|
align-items: center;
|
|
border: 1px solid blue;
|
|
-webkit-user-select: none;
|
|
margin: 5px;'''
|
|
);
|
|
|
|
static final Style _highlightStyle = new Style('''
|
|
transform: translateX(0);
|
|
display: inline-flex;
|
|
border-radius: 4px;
|
|
justify-content: center;
|
|
align-items: center;
|
|
border: 1px solid blue;
|
|
-webkit-user-select: none;
|
|
margin: 5px;
|
|
background-color: orange;'''
|
|
);
|
|
|
|
Node content;
|
|
|
|
Button({ Object key, this.content }) : super(key: key);
|
|
|
|
Node build() {
|
|
return new Material(
|
|
style: highlight ? _highlightStyle : _style,
|
|
children: [content]
|
|
);
|
|
}
|
|
}
|