Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Unified Diff: sky/examples/editor/editable_text.dart

Issue 983213005: Move material Input component into sky/framework (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/examples/editor/editable_string.dart ('k') | sky/examples/editor/editor_app.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/editor/editable_text.dart
diff --git a/sky/examples/editor/editable_text.dart b/sky/examples/editor/editable_text.dart
deleted file mode 100644
index d752972f1f1194526c40eb4c1094e5aaa16266b8..0000000000000000000000000000000000000000
--- a/sky/examples/editor/editable_text.dart
+++ /dev/null
@@ -1,97 +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 '../../framework/fn.dart';
-import '../../framework/theme/colors.dart';
-import 'dart:async';
-import 'editable_string.dart';
-
-class EditableText extends Component {
- static final Style _style = new Style('''
- display: inline;'''
- );
-
- static final Style _cusorStyle = new Style('''
- display: inline-block;
- width: 2px;
- height: 1.2em;
- vertical-align: top;
- background-color: ${Blue[500]};'''
- );
-
- static final Style _composingStyle = new Style('''
- display: inline;
- text-decoration: underline;'''
- );
-
- EditableString value;
- bool focused;
- Timer _cursorTimer;
- bool _showCursor = false;
-
- EditableText({Object key, this.value, this.focused})
- : super(key: key, stateful: true) {
- }
-
- void _cursorTick(Timer timer) {
- setState(() {
- _showCursor = !_showCursor;
- });
- }
-
- void _startCursorTimer() {
- _showCursor = true;
- _cursorTimer = new Timer.periodic(
- new Duration(milliseconds: 500), _cursorTick);
- }
-
- void _stopCursorTimer() {
- _cursorTimer.cancel();
- _cursorTimer = null;
- _showCursor = false;
- }
-
- void didUnmount() {
- if (_cursorTimer != null)
- _stopCursorTimer();
- }
-
- Node build() {
- if (focused && _cursorTimer == null)
- _startCursorTimer();
- else if (!focused && _cursorTimer != null)
- _stopCursorTimer();
-
- List<Node> children = new List<Node>();
-
- if (!value.composing.isValid) {
- children.add(new Text(value.text));
- } else {
- String beforeComposing = value.textBefore(value.composing);
- if (!beforeComposing.isEmpty)
- children.add(new Text(beforeComposing));
-
- String composing = value.textInside(value.composing);
- if (!composing.isEmpty) {
- children.add(new Container(
- key: 'composing',
- style: _composingStyle,
- children: [new Text(composing)]
- ));
- }
-
- String afterComposing = value.textAfter(value.composing);
- if (!afterComposing.isEmpty)
- children.add(new Text(afterComposing));
- }
-
- if (_showCursor)
- children.add(new Container(key: 'cursor', style: _cusorStyle));
-
- return new Container(
- style: _style,
- children: children
- );
- }
-}
« no previous file with comments | « sky/examples/editor/editable_string.dart ('k') | sky/examples/editor/editor_app.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698