raised_button.dart 1.15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
// 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 'package:sky/theme/colors.dart' as colors;
import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/material_button.dart';
import 'package:sky/widgets/theme.dart';

class RaisedButton extends MaterialButton {

  RaisedButton({
13
    Key key,
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
    Widget child,
    bool enabled: true,
    Function onPressed
  }) : super(key: key,
             child: child,
             enabled: enabled,
             onPressed: onPressed);

  Color get color {
    if (enabled) {
      switch (Theme.of(this).brightness) {
        case ThemeBrightness.light:
          if (highlight)
            return colors.Grey[350];
          else
            return colors.Grey[300];
          break;
        case ThemeBrightness.dark:
          if (highlight)
            return Theme.of(this).primarySwatch[700];
          else
            return Theme.of(this).primarySwatch[600];
          break;
      }
    } else {
      return colors.Grey[350];
    }
  }

  int get level => enabled ? (highlight ? 2 : 1) : 0;
}