import 'package:base_app/models/common/component_model.dart';
import 'package:base_app/res/index.dart';
import 'package:base_app/utils/util_index.dart';
import 'package:flutter/material.dart';

class ComArrowItem extends StatelessWidget {
  const ComArrowItem(this.model, {Key key}) : super(key: key);
  final ComponentModel model;

  @override
  Widget build(BuildContext context) {
    return new Container(
      child: new Material(
        color: Colors.white,
        child: new ListTile(
          onTap: () {
            if (model.page == null && model.url != null) {
              // 跳转网页
              NavigatorUtil.pushWeb(context,
                  title: model.title, url: model.url);
            } else {
              // 跳转页面
              NavigatorUtil.pushPage(context, model.page,
                  pageName: model.title);
            }
          },
          // 标题
          title: new Text(model.title == null ? "" : model.title),
          trailing: new Row(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              new Text(
                // 其他文字
                model.extra == null ? "" : model.extra,
                style: TextStyle(color: Colors.grey, fontSize: 14.0),
              ),
              new Icon(
                // 向右箭头
                Icons.navigate_next,
                color: Colors.grey,
              ),
            ],
          ),
        ),
      ),
      decoration: Decorations.bottom,
    );
  }
}
