|
|
|
@ -1,8 +1,16 @@
|
|
|
|
|
import 'package:flutter/Material.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
|
import 'package:justmusic/main.dart';
|
|
|
|
|
import 'package:justmusic/values/constants.dart';
|
|
|
|
|
import 'package:tuple/tuple.dart';
|
|
|
|
|
|
|
|
|
|
import '../model/Music.dart';
|
|
|
|
|
|
|
|
|
|
class HistoricComponent extends StatefulWidget {
|
|
|
|
|
final int month;
|
|
|
|
|
const HistoricComponent({super.key, required this.month});
|
|
|
|
|
final int year;
|
|
|
|
|
const HistoricComponent({super.key, required this.month, required this.year});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<HistoricComponent> createState() => _HistoricComponentState();
|
|
|
|
@ -17,27 +25,74 @@ class _HistoricComponentState extends State<HistoricComponent> {
|
|
|
|
|
return DateTime(year, month + 1, 0).day;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getHistoric() {}
|
|
|
|
|
List<Tuple2<int, Music>> historic = [
|
|
|
|
|
Tuple2(1, MyApp.postViewModel.bestPosts.first.music),
|
|
|
|
|
Tuple2(3, MyApp.postViewModel.bestPosts.first.music),
|
|
|
|
|
Tuple2(11, MyApp.postViewModel.bestPosts.first.music)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Wrap(
|
|
|
|
|
spacing: 14,
|
|
|
|
|
runSpacing: 14,
|
|
|
|
|
children: List.generate(getNumberOfDaysInMonth(DateTime.now().year, widget.month), (index) {
|
|
|
|
|
// Generate widgets
|
|
|
|
|
return LimitedBox(
|
|
|
|
|
maxWidth: MediaQuery.of(context).size.width - 40 / 5,
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
gradient: LinearGradient(colors: [
|
|
|
|
|
Color(0xFF1E1E1E).withOpacity(0.7),
|
|
|
|
|
Color(0xFF1E1E1E).withOpacity(0),
|
|
|
|
|
], begin: Alignment.topCenter, end: Alignment.bottomCenter),
|
|
|
|
|
borderRadius: BorderRadius.circular(3)),
|
|
|
|
|
height: 60,
|
|
|
|
|
width: 60,
|
|
|
|
|
),
|
|
|
|
|
return FutureBuilder(
|
|
|
|
|
future: ,
|
|
|
|
|
builder: (context, snapshot){
|
|
|
|
|
if(snapshot.hasData){
|
|
|
|
|
return Wrap(
|
|
|
|
|
spacing: 14,
|
|
|
|
|
runSpacing: 14,
|
|
|
|
|
children: List.generate(getNumberOfDaysInMonth(widget.year, widget.month), (index) {
|
|
|
|
|
Tuple2<int, Music>? checkCapsule;
|
|
|
|
|
for (var element in historic) {
|
|
|
|
|
if (element.item1 == index + 1) {
|
|
|
|
|
checkCapsule = element;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((widget.year > DateTime.now().year || widget.month > DateTime.now().month) ||
|
|
|
|
|
(widget.year == DateTime.now().year &&
|
|
|
|
|
widget.month == DateTime.now().month &&
|
|
|
|
|
index > DateTime.now().day)) {
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
gradient: LinearGradient(colors: [
|
|
|
|
|
Color(0xFF1E1E1E).withOpacity(0.7),
|
|
|
|
|
Color(0xFF1E1E1E).withOpacity(0),
|
|
|
|
|
], begin: Alignment.topCenter, end: Alignment.bottomCenter),
|
|
|
|
|
borderRadius: BorderRadius.circular(5)),
|
|
|
|
|
height: 60,
|
|
|
|
|
width: 60,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (checkCapsule != null) {
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
image: DecorationImage(image: NetworkImage((checkCapsule.item2.cover)!)),
|
|
|
|
|
borderRadius: BorderRadius.circular(5)),
|
|
|
|
|
height: 60,
|
|
|
|
|
width: 60,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Container(
|
|
|
|
|
color: bgColor,
|
|
|
|
|
height: 60,
|
|
|
|
|
width: 60,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Text(
|
|
|
|
|
(index + 1).toString(),
|
|
|
|
|
style: GoogleFonts.plusJakartaSans(color: Colors.white, fontSize: 22, fontWeight: FontWeight.w800),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generate widgets
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return CupertinoActivityIndicator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|