import 'package:flutter/material.dart';

import 'database.dart';
import 'drawer.dart';

class Actor extends StatelessWidget {
  // The indexes of each array match the assigned recipe.
  // DO NOT loop through each of these individually
  // to generate the recipes.

  @override
  Widget build(BuildContext context) {
    var text_style = TextStyle(
      fontWeight: FontWeight.bold,
      fontSize: 20,
    );
    movieData.sort((a, b) => a['actorname'].compareTo(b['actorname']));
    return Scaffold(
      appBar: AppBar(
        // The title text which will be shown on the action bar
        title: Center(child: Text("By Actor")),
      ),
      drawer: Container(
        color: Colors.grey,
        child: AppDrawer(),
      ), //Appbar
      body: ListView(children: [
        for (var point = 0; point < movieData.length; point++)
          Container(
              child: Flex(
                direction: Axis.horizontal,
                textDirection: TextDirection.ltr,
                children: [
                  Expanded(
                      flex: 1,
                      child: Container(
                          child: Image.asset('assets/poster/' +
                              movieData[point]["actorimage"]),
                          margin: EdgeInsets.fromLTRB(0, 0, 10, 0))),
                  Expanded(
                      flex: 1,
                      child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Container(
                                child: Text(movieData[point]["actorname"],
                                    style: text_style),
                                margin: EdgeInsets.fromLTRB(0, 0, 2, 2)),
                            Container(
                              child: Text(
                                  'Movie:' + movieData[point]["movietitle"],
                                  style: TextStyle(
                                      fontSize: 18,
                                      fontStyle: FontStyle.italic)),
                            ),
                            Container(
                              child: Row(
                                children: [
                                  Text(
                                    "Release Date",
                                    style: TextStyle(
                                      fontSize: 18,
                                    ),
                                  ),
                                  Text(movieData[point]["releasedate"],
                                      style: TextStyle(
                                          fontSize: 18,
                                          fontStyle: FontStyle.italic)),
                                ],
                              ),
                            )
                          ]))
                ],
              ),
              margin: EdgeInsets.fromLTRB(0, 0, 0, 10))
      ]),
    ); //Scaffold
  } //build
}
