


import 'package:bus_infotainment/audio_cache.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class AudioCacheTest extends StatelessWidget {

  AnnouncementCache _announcementCache = AnnouncementCache();

  AudioCacheTest({super.key}) {

  }


  @override
  Widget build(BuildContext context) {

    return Scaffold(

      appBar: AppBar(
        title: Text(
          "AudioCacheTest"
        )
      ),

      body: Container(
        child: FutureBuilder(
          future: Future.delayed(Duration(seconds: 1)), //todo
          builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
            if (snapshot.connectionState == ConnectionState.done) {
              
              List<Widget> announcements = [];
              
              for (var key in _announcementCache.keys) {
              
                announcements.add(
                  ElevatedButton(
                    onPressed: () {
                      // AudioPlayer player = AudioPlayer();
                      // player.play(BytesSource(_announcementCache[key]));
                    },
                    child: Text(
                      key
                    )
                  )
                );
              }
                
              return ListView(
                children: announcements,
              );
            } else {
              return const CircularProgressIndicator();
            }
          }
        )
      ),

    );
  }

}