import 'package:fcs/pages/contact/contact_page.dart';
import 'package:fcs/pages/main/model/main_model.dart';
import 'package:fcs/pages/term/term_page.dart';
import 'package:fcs/pages/widgets/local_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_icons/flutter_icons.dart';
import 'package:provider/provider.dart';

class BottomWidgets extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var pkgInfo = Provider.of<MainModel>(context).packageInfo;
    final versionBox = Text(
      "v${pkgInfo.version}+${pkgInfo.buildNumber}",
      style: TextStyle(color: Colors.white30),
    );
    return Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            InkWell(
              onTap: () {
                Navigator.of(context).push(
                    CupertinoPageRoute(builder: (context) => ContactPage()));
              },
              child: _buildSmallButton(
                  context, "contact.btn", SimpleLineIcons.support),
            ),
            InkWell(
              onTap: () {
                Navigator.of(context)
                    .push(CupertinoPageRoute(builder: (context) => TermPage()));
              },
              child: _buildSmallButton(context, "term.btn", Icons.info_outline),
            ),
          ],
        ),
        Padding(
          padding: const EdgeInsets.only(bottom: 8.0),
          child: versionBox,
        ),
      ],
    );
  }

  Widget _buildSmallButton(
      BuildContext context, String textKey, IconData iconData) {
    return Padding(
      padding: const EdgeInsets.all(18.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Padding(
            padding: const EdgeInsets.only(right: 5),
            child: Icon(iconData, color: Colors.white70, size: 20),
          ),
          LocalText(context, textKey, color: Colors.white70)
        ],
      ),
    );
  }
}
