mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Split layout2.dart into several files
Previously layout2.dart was a thousand lines long. R=ianh@google.com Review URL: https://codereview.chromium.org/1161003002
This commit is contained in:
parent
46e47cf011
commit
dbbe62ea8f
@ -4,7 +4,10 @@
|
||||
|
||||
import 'dart:sky';
|
||||
import 'package:sky/framework/app.dart';
|
||||
import 'package:sky/framework/layout2.dart';
|
||||
import 'package:sky/framework/rendering/render_box.dart';
|
||||
import 'package:sky/framework/rendering/render_node.dart';
|
||||
import 'package:sky/framework/rendering/render_flex.dart';
|
||||
import 'package:sky/framework/rendering/render_paragraph.dart';
|
||||
|
||||
class RenderSolidColor extends RenderDecoratedBox {
|
||||
final Size desiredSize;
|
||||
@ -15,7 +18,7 @@ class RenderSolidColor extends RenderDecoratedBox {
|
||||
super(decoration: new BoxDecoration(backgroundColor: backgroundColor));
|
||||
|
||||
Size getIntrinsicDimensions(BoxConstraints constraints) {
|
||||
return constraints.constrain(new Size(desiredWidth, desiredHeight));
|
||||
return constraints.constrain(desiredSize);
|
||||
}
|
||||
|
||||
void performLayout() {
|
||||
|
@ -5,7 +5,8 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:sky' as sky;
|
||||
import 'package:sky/framework/app.dart';
|
||||
import 'package:sky/framework/layout2.dart';
|
||||
import 'package:sky/framework/rendering/render_box.dart';
|
||||
import 'package:sky/framework/rendering/render_node.dart';
|
||||
|
||||
const double kTwoPi = 2 * math.PI;
|
||||
|
@ -1,87 +0,0 @@
|
||||
// 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 'dart:sky' as sky;
|
||||
import 'package:sky/framework/app.dart';
|
||||
import 'package:sky/framework/layout2.dart';
|
||||
|
||||
class RenderSolidColor extends RenderDecoratedBox {
|
||||
final sky.Size desiredSize;
|
||||
final int backgroundColor;
|
||||
|
||||
RenderSolidColor(int backgroundColor, { this.desiredSize: const sky.Size.infinite() })
|
||||
: backgroundColor = backgroundColor,
|
||||
super(decoration: new BoxDecoration(backgroundColor: backgroundColor)) {
|
||||
}
|
||||
|
||||
BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) {
|
||||
return new BoxDimensions.withConstraints(constraints,
|
||||
width: desiredSize.width,
|
||||
height: desiredSize.height);
|
||||
}
|
||||
|
||||
void performLayout() {
|
||||
size = constraints.constrain(desiredSize);
|
||||
}
|
||||
|
||||
void handlePointer(sky.PointerEvent event) {
|
||||
if (event.type == 'pointerdown')
|
||||
decoration = new BoxDecoration(backgroundColor: 0xFFFF0000);
|
||||
else if (event.type == 'pointerup')
|
||||
decoration = new BoxDecoration(backgroundColor: backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
AppView app;
|
||||
|
||||
void main() {
|
||||
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.Vertical);
|
||||
|
||||
RenderNode root = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: 0xFF000000),
|
||||
child: flexRoot
|
||||
);
|
||||
|
||||
void addFlexChildSolidColor(RenderFlex parent, int backgroundColor, { int flex: 0 }) {
|
||||
RenderNode child = new RenderSolidColor(backgroundColor);
|
||||
parent.add(child);
|
||||
child.parentData.flex = flex;
|
||||
}
|
||||
|
||||
// Yellow bar at top
|
||||
addFlexChildSolidColor(flexRoot, 0xFFFFFF00, flex: 1);
|
||||
|
||||
// Turquoise box
|
||||
flexRoot.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(100.0, 100.0)));
|
||||
|
||||
// Green and cyan render block with padding
|
||||
var renderBlock = new RenderBlock();
|
||||
|
||||
renderBlock.add(new RenderSolidColor(0xFF00FF00, desiredSize: new sky.Size(100.0, 50.0)));
|
||||
renderBlock.add(new RenderSolidColor(0x7700FFFF, desiredSize: new sky.Size(50.0, 100.0)));
|
||||
|
||||
var renderDecoratedBlock = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: 0xFFFFFFFF),
|
||||
child: renderBlock
|
||||
);
|
||||
|
||||
flexRoot.add(new RenderPadding(const EdgeDims(10.0, 10.0, 10.0, 10.0), renderDecoratedBlock));
|
||||
|
||||
var row = new RenderFlex(direction: FlexDirection.Horizontal);
|
||||
|
||||
// Purple and blue cells
|
||||
addFlexChildSolidColor(row, 0x77FF00FF, flex: 1);
|
||||
addFlexChildSolidColor(row, 0xFF0000FF, flex: 2);
|
||||
|
||||
var decoratedRow = new RenderDecoratedBox(
|
||||
decoration: new BoxDecoration(backgroundColor: 0xFF333333),
|
||||
child: row
|
||||
);
|
||||
|
||||
flexRoot.add(decoratedRow);
|
||||
decoratedRow.parentData.flex = 3;
|
||||
|
||||
app = new AppView(root);
|
||||
|
||||
}
|
@ -5,7 +5,8 @@
|
||||
import 'dart:math';
|
||||
import 'dart:sky';
|
||||
import 'package:sky/framework/app.dart';
|
||||
import 'package:sky/framework/layout2.dart';
|
||||
import 'package:sky/framework/rendering/render_box.dart';
|
||||
import 'package:sky/framework/rendering/render_node.dart';
|
||||
|
||||
// Material design colors. :p
|
||||
List<int> colors = [
|
||||
|
@ -23,7 +23,6 @@ import 'stock_data.dart';
|
||||
// import 'stock_menu.dart';
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:sky/framework/layout2.dart';
|
||||
|
||||
enum StockMode { Optimistic, Pessimistic }
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
import 'dart:math';
|
||||
import 'package:sky/framework/fn2.dart';
|
||||
import 'package:sky/framework/layout2.dart';
|
||||
|
||||
class StockArrow extends Component {
|
||||
static final Style _style = new Style('''
|
||||
|
@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:sky/framework/fn2.dart';
|
||||
import 'package:sky/framework/layout2.dart';
|
||||
import 'package:sky/framework/components2/popup_menu.dart';
|
||||
import 'package:sky/framework/components2/checkbox.dart';
|
||||
import 'package:sky/framework/theme/view_configuration.dart';
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
import 'package:sky/framework/components2/ink_well.dart';
|
||||
import 'package:sky/framework/fn2.dart';
|
||||
import 'package:sky/framework/layout2.dart';
|
||||
import 'package:sky/framework/theme/typography.dart' as typography;
|
||||
import 'stock_arrow.dart';
|
||||
import 'stock_data.dart';
|
||||
|
Loading…
Reference in New Issue
Block a user