
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_wisetronic/widgets/general/bottom_nav.dart';

import '../../constants.dart';
import '../../generated/l10n.dart';
import '../../models/blog.dart';
import '../../widgets/general/breadcrumbs.dart';
import '../../widgets/general/navigationbar.dart';

class DesktopPlainPage extends StatefulWidget {
  final Blog blog;

  const DesktopPlainPage(this.blog, {Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return DesktopPlainPageState();
  }

}

class DesktopPlainPageState extends State<DesktopPlainPage> {
  double sideSpace = 0;
  double mainSpace = 1200;

  @override
  Widget build(BuildContext context) {
    if (MediaQuery.of(context).size.width <= 1200) {
      mainSpace = MediaQuery.of(context).size.width;
      sideSpace = 0;
    } else {
      mainSpace = 1200;
      sideSpace = (MediaQuery.of(context).size.width - 1200) / 2;
    }

    Column col = Column(
      children: [],
    );
    col.children.add(Container(
      padding: EdgeInsets.only(top: 20, left: 16.0, right: 16.0, bottom: 16.0),
      child: Center(
        child: Text(
          widget.blog.title,
          style: TextStyle(
            fontWeight: FontWeight.bold,
            fontSize: 20,
          ),
        ),
      ),
    ));
    col.children.add(Container(
      padding: EdgeInsets.only(left: 16.0, right: 16.0, bottom: 20.0),
      child: MarkdownBody(
        shrinkWrap: true,
        data: widget.blog.body,
      ),
    ));

    return Scaffold(
      appBar: MiniNavigationBar(
        title: S.of(context).blog,
        back: true,
        breadCrumbs: [
          BreadCrumb(widget.blog.title, null),
        ],
        breadCrumbHeight: Constants.BREADCRUMB_HEIGHT,
      ),
      body: SingleChildScrollView(
        child: Row(
          children: [
            Container(
              width: sideSpace,
            ),
            Expanded(child: col,),
            Container(
              width: sideSpace,
            ),
          ],
        ),
      ),
      bottomNavigationBar: BottomNav(),
    );
  }

}