-
Notifications
You must be signed in to change notification settings - Fork 0
/
RockInRio.dart
143 lines (128 loc) · 4.05 KB
/
RockInRio.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import 'package:flutter/material.dart';
void main() {
runApp(const RockInRio());
}
class RockInRio extends StatelessWidget {
const RockInRio ({ Key? key}) : super (key:key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Rock In Rio App',
debugShowCheckedModeBanner: false,
theme: ThemeData(primarySwatch: Colors.indigo),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final List<Atracao> _listaFavoritos = [];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Atrações'),
),
body: ListView.builder(
itemCount: listaAtracoes.length,
itemBuilder: (context, index) {
final isFavorito = _listaFavoritos.contains(listaAtracoes[index]);
return ListTile(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
AtracaoPage(
atracao: listaAtracoes[index]
)
));
},
title: Text(listaAtracoes[index].nome),
subtitle: Wrap(
spacing: 8,
runSpacing: 4,
children: listaAtracoes[index]
.tags
.map((tag) =>
Chip(label: Text('$tag'))
)
.toList(),
),
leading: CircleAvatar(
child: Text('${listaAtracoes[index].dia}')
),
trailing: IconButton(
onPressed: () {
setState(() {
if (isFavorito) {
_listaFavoritos.remove(listaAtracoes[index]);
}
else {
_listaFavoritos.add(listaAtracoes[index]);
}
});
},
icon: isFavorito ?
const Icon(Icons.favorite, color: Colors.red)
: const Icon(Icons.favorite_border),
),
);
},
)
);
}
}
class Atracao {
final String nome;
final int dia;
final List<String> tags;
const Atracao(this.nome, this.dia, this.tags);
}
class AtracaoPage extends StatelessWidget {
final Atracao atracao;
const AtracaoPage({Key? key, required this.atracao}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(atracao.nome),
),
body: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
for (var tag in atracao.tags)
Chip(label: Text('#$tag')),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Voltar'),
)
],
),
),
);
}
}
const listaAtracoes = [
Atracao("Iron Maiden", 2, ["Espetaculo", "Fas", "NovoAlbum"]),
Atracao("Alok", 3, ["Influente", "Top", "Show"]),
Atracao("Justin Bieber", 4, ["TopCharts", "Hits", "PríncipeDoPOP"]),
Atracao("Guns N’ Roses", 8, ["Sucesso", "Espetáculo", "Fas"]),
Atracao("Capital Inicial", 9, ["2019", "Novo Álbum", "Fas"]),
Atracao("Green Day", 9, ["Sucesso", "Reconhecimento", "Show"]),
Atracao("Cold Play", 10, ["NovoAlbum", "Sucesso", "2011"]),
Atracao("Ivete Sangalo", 10, ["Unica", "Carreiras", "Fas"]),
Atracao("Racionais", 3, ["Hits", "Prêmios", "Respeito"]),
Atracao("Gloria Groove", 8, ["Streams", "Representatividade", "Sucesso"]),
Atracao("Avril Lavigne", 9, ["Estreia", "Sucesso", "Lançamento"]),
Atracao("Ludmilla", 10, ["Representativade", "Sucesso", "Parcerias"]),
];