import 'dart:ui';

import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
import 'package:aitrainer_app/util/common.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

// ignore: must_be_immutable
class MenuInfoWidget extends StatelessWidget with Common {
  final String title;
  final double titleSize;
  final Color titleColor;
  final FontWeight titleWeight;
  final String text;
  final double textSize;
  final Color textColor;
  final FontWeight textWeight;
  final Icon leadingIcon;
  final Color leadingIconColor;
  final String text2;
  final String text3;
  final String link;
  final int parentMenu;
  final MenuBloc bloc;

  MenuInfoWidget(
      {this.title,
      this.titleSize,
      this.titleColor,
      this.titleWeight,
      @required this.text,
      this.textSize,
      this.textColor,
      this.textWeight,
      this.leadingIcon,
      this.leadingIconColor,
      this.text2,
      this.text3,
      this.link,
      this.parentMenu,
      this.bloc});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 10.0, left: 15, right: 10, bottom: 5),

      decoration: BoxDecoration(
        color: Colors.black.withOpacity(0.5),
        border: Border.all(color: Colors.white60),
        borderRadius: BorderRadius.all(Radius.circular(16.0)),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(
            title,
            maxLines: 4,
            textAlign: TextAlign.center,
            style: TextStyle(color: titleColor, fontSize: titleSize, fontWeight: titleWeight),
          ),
          Divider(),
          Text(
            text,
            maxLines: 6,
            style: TextStyle(color: textColor, fontSize: textSize, fontWeight: textWeight),
          ),
          /* Divider(),
          Text(
            text2,
            maxLines: 6,
            style: TextStyle(
                color: textColor, fontSize: textSize, fontWeight: textWeight),
          ), */
          Divider(),
          Text(
            text3,
            maxLines: 6,
            style: TextStyle(color: textColor, fontSize: textSize, fontWeight: textWeight),
          ),
          getLink(),
        ],
      ),
      //),
      //    )
    );
  }

  Widget getLink() {
    int missingId;
    return InkWell(
        child: new Text(
          link,
          style: TextStyle(color: Colors.lightBlueAccent, fontSize: textSize, fontFamily: 'Arial', fontWeight: textWeight),
        ),
        onTap: () =>
            {missingId = bloc.menuTreeRepository.getMissingTreeIdByName(bloc.missingTreeName), bloc.add(MenuTreeJump(parent: missingId))});
  }
}