2024-09-30 16:44:37 +04:00
|
|
|
import 'package:flutter/material.dart';
|
2024-10-03 11:45:55 +04:00
|
|
|
import 'models/album.dart';
|
|
|
|
import 'repositories/album_repository.dart';
|
|
|
|
import 'services/album_service.dart';
|
|
|
|
import 'widgets/album_card.dart';
|
2024-09-30 16:44:37 +04:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
2024-10-03 11:45:55 +04:00
|
|
|
title: 'Music Reviewer',
|
|
|
|
theme: ThemeData.dark().copyWith(
|
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.purpleAccent)
|
2024-09-30 16:44:37 +04:00
|
|
|
),
|
2024-10-03 11:45:55 +04:00
|
|
|
home: const MyHomePage(title: 'Music Reviewer'),
|
2024-09-30 16:44:37 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key, required this.title});
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2024-10-03 11:45:55 +04:00
|
|
|
final AlbumRepository _albumRepository = AlbumRepository();
|
|
|
|
List<Album> _albums = [];
|
2024-09-30 16:44:37 +04:00
|
|
|
|
2024-10-03 11:45:55 +04:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_loadAlbums();
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _loadAlbums() async {
|
|
|
|
_albums = await fetchAlbums();
|
|
|
|
setState(() {});
|
2024-09-30 16:44:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
|
|
title: Text(widget.title),
|
|
|
|
),
|
2024-10-03 11:45:55 +04:00
|
|
|
body: ListView.builder(
|
|
|
|
itemCount: _albums.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final album = _albums[index];
|
|
|
|
return AlbumCard(album: album);
|
|
|
|
},
|
2024-09-30 17:18:25 +04:00
|
|
|
),
|
2024-09-30 16:44:37 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|