import 'package:flutter/material.dart';
import 'package:softplayer_web/models/catalog_entry.dart';

class CatalogCard extends StatelessWidget {
  const CatalogCard({
    super.key,
    required this.data,
  });
  final List<CatalogEntry> data;

  List<Widget> createCards(List<CatalogEntry> data) {
    List<Widget> createCards = [];
    for (var app in data) {
      createCards.add(Card(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            ListTile(
              //leading: Image.network(app.logoUrl),
              leading: const Icon(Icons.nfc),
              title: Text(app.name),
              subtitle: Text(app.description),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: <Widget>[
                TextButton(
                  child: const Text('INSTALL'),
                  onPressed: () {
                    print("installing");
                  },
                ),
                const SizedBox(width: 8),
              ],
            ),
          ],
        ),
      ));
    }
    return createCards;
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: createCards(data),
    );
  }
}
