import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'dart:convert'; import 'dart:async'; import 'main.dart'; abstract class BaseState extends State { bool loading = false; String error = null; String textFieldValue = ""; AppBar getAppBar() { return new AppBar(title: new Text(getTitle(), style: new TextStyle(fontSize: 18.0)), backgroundColor: primaryColor, actions: getMenuButtons()); } String getTitle(); String getHint(); getMenuButtons(); /// Метод возвращает контейнер с отступами, который содержит картинку с логотипом. getLogo() { double containerHeight = 92.0; double imageWidth = 156.0; return new Container(height: containerHeight, child: new Image.asset(logo_png, width: imageWidth)); } getHintLabel() { double horizontalMargin = 8.0; return new Container(margin: new EdgeInsets.only(top: horizontalMargin, bottom: horizontalMargin, left: verticalMargin, right: verticalMargin), child: new Row(crossAxisAlignment: CrossAxisAlignment.start, children: [new Text(getHintText(), overflow: TextOverflow.ellipsis, textAlign: TextAlign.left, style: new TextStyle(fontWeight: FontWeight.w300, color: error == null ? greyTextColor : primaryColor, fontSize: 14.0))])); } getHintText() { if (textFieldValue.length == 0 && error == null) { return ' '; } else if (error != null) { return error; } else { return getHint(); } } /// Метод возвращает контейнер с установленными отступами, в котором размещен TextField обернутый в BoxDecoration. getDecoratedTextWidget() { return new Container(margin: new EdgeInsets.only(left: verticalMargin, right: verticalMargin), padding: getPaddingForTextWidget(), decoration: getDecoraionForTextWidget(), child: getTextWidget()); } getPaddingForTextWidget() { const double verticalPadding = 12.0; const double horizontalPadding = 16.0; return new EdgeInsets.only(top: verticalPadding, bottom: verticalPadding, left: horizontalPadding, right: horizontalPadding); } /// Метод возвращает BoxDecoration для _getDecoratedInputField getDecoraionForTextWidget() { return new BoxDecoration(color: textFieldBackground, border: new Border.all(color: textBorderColor, width: 1.0,), borderRadius: new BorderRadius.all(new Radius.circular(4.0))); } Widget getTextWidget() { return new TextField(keyboardType: TextInputType.number, decoration: new InputDecoration.collapsed(hintText: getHint(), hintStyle: new TextStyle(color: greyTextColor, fontSize: 16.0)), onChanged: (text) => _handleUserInput(text)); } /// Индикация ... Widget getProgressIndicator() { return new Center(child: loading ? new CircularProgressIndicator() : null); } }