import 'package:flutter/material.dart';
import 'package:namer_app/datatable.dart';
import 'package:namer_app/footer.dart';
import 'package:namer_app/header.dart';

class ListTablePage extends StatelessWidget {
  const ListTablePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Header(
        title: Text('title'),
        appBar: AppBar(),
        widgets: <Widget>[Icon(Icons.more_vert)],
      ),
      body: Stack(children: [
        SingleChildScrollView(
          child: Column(
            children: [
              Center(
                  child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    'Maintenance',
                    style: TextStyle(color: Colors.black, fontSize: 48),
                  ),
                ],
              )),
              Column(
                children: List.generate(
                    5,
                    (i) => SizedBox(
                          child: ListTile(
                            leading: SizedBox(
                              child: Icon(Icons.table_bar),
                            ),
                            title: Text(tables[i]['table']),
                            trailing: ButtonUser(
                              items: tables[i],
                            ),
                          ),
                        )),
              ),
            ],
          ),
        ),
      ]),
      bottomNavigationBar: Footer(),
    );
  }
}

class ButtonUser extends StatelessWidget {
  final Map<String, dynamic> items;
  ButtonUser({
    required this.items,
    super.key,
  });
  //todo tombol item
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        ElevatedButton(
          onPressed: null,
          style: ElevatedButton.styleFrom(
            backgroundColor: Colors.black,
          ),
          child: Text(
            'Backup',
            style: TextStyle(color: Colors.white),
          ),
        ),
        ElevatedButton(
          onPressed: null,
          style: ElevatedButton.styleFrom(
            backgroundColor: Colors.black,
          ),
          child: Text(
            'Restore',
            style: TextStyle(color: Colors.white),
          ),
        ),
      ],
    );
  }
}