Skip to content

Instantly share code, notes, and snippets.

@dpossas
Last active December 5, 2019 19:30
Show Gist options
  • Save dpossas/afc4159b171477fc3531f098f272c5ca to your computer and use it in GitHub Desktop.
Save dpossas/afc4159b171477fc3531f098f272c5ca to your computer and use it in GitHub Desktop.
Frases dos personagens de Chaves
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
final mrMadruga = Character("Seu Madruga",
"https://i.pinimg.com/236x/95/5c/4d/955c4d32d280d606df214c7f0aa2e061--humor-meme-funny-jokes.jpg");
final florinda = Character("Dona Florinda",
"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQJcyNPoY83KMBi_nD1ws_LwWWa_rP3ZVVXJn427QHFZrsFro9g");
final quico = Character("Quico",
"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcTnTrtHuqaznYXzdyrDA7FY4ZTN1E_1C3UbuCQT6fLf8feBnHRU");
final mrBarriga = Character("Senhor Barriga",
"http://1.bp.blogspot.com/-VyvNC0I5Mco/ViPfWRkz_nI/AAAAAAAAAmw/bujANDzX5Ow/s1600/seu-barriga.jpg");
final chaves = Character("Chaves",
"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRyoEY_fo7qqRD5Vt5RqWm3DCY2bjGYre0mSFr2HB4b5bQsCq65");
final professorGirafales = Character("Professor Girafales",
"https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRnps_k2h2C-nCdqYXJDRgQphCOaqoEo0TEt6kYbOSM0u63BMgp");
List<Phrase> phrases = [
Phrase(mrMadruga, "Tinha que ser o Chaves de novo!"),
Phrase(florinda, "Não se misture com essa gentalha, tesouro!"),
Phrase(quico, "Você não vai com a minha cara?!"),
Phrase(mrBarriga, "Pague o aluguel!!!"),
Phrase(chaves, "Ta bom mas não se irrite..."),
Phrase(professorGirafales, "Qual é o maior animal que vive sobre a terra?"),
Phrase(chaves,
"Volta o cão arrependido com suas orelhas bem fartas, com o seu osso ruído e com o rabo estre as patas"),
Phrase(mrMadruga,
"É que eu não entendo como é que em tão pouco tempo se consegue ficar tão burro!"),
Phrase(chaves, "Pipipipipipi"),
Phrase(quico, "rrrrrrrrrrrrrrrrrrrrr"),
];
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.light(),
debugShowCheckedModeBanner: false,
home: PhrasesOfChavesWidget(),
);
}
}
class PhrasesOfChavesWidget extends StatefulWidget {
@override
_PhrasesOfChavesWidgetState createState() => _PhrasesOfChavesWidgetState();
}
class _PhrasesOfChavesWidgetState extends State<PhrasesOfChavesWidget> {
String _typeOfView = "list";
void _setListView() {
setState((){
_typeOfView = "list";
});
}
void _setGridView() {
setState((){
_typeOfView = "grid";
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: Text("Frases do seriado Chaves"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.list),
onPressed: _setListView,
),
IconButton(
icon: Icon(Icons.grid_on),
onPressed: _setGridView,
),
],
),
body: _typeOfView == "list" ? ListPhrasesWidget() : GridPhrasesWidget(),
);
}
}
class GridPhrasesWidget extends StatelessWidget {
Widget build(BuildContext context) {
return GridView.count(
crossAxisCount: 1,
scrollDirection: Axis.horizontal,
padding: EdgeInsets.all(4.0),
children: phrases.map((phrase) => gridCardWidget(phrase)).toList(),
);
}
}
class ListPhrasesWidget extends StatelessWidget {
Widget build(BuildContext context) {
return ListView.builder(
itemCount: phrases.length,
itemBuilder: (context, index) {
Phrase phrase = phrases[index];
return cardWidget(phrase);
},
);
}
}
Widget gridCardWidget(Phrase phrase) {
return Card(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: EdgeInsets.all(8),
child: ClipOval(
child: Image.network(
phrase.character.avatarUrl,
fit: BoxFit.cover,
width: 80.0,
height: 80.0,
),
),
),
Padding(
padding: EdgeInsets.all(8),
child: Text(
"${phrase.character.name}",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 40),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: "\"",
style: TextStyle(
color: Colors.black87,
fontSize: 24,
fontFamily: "roboto"
),
children: <TextSpan>[
TextSpan(
text: "${phrase.content}",
style: TextStyle(
fontStyle: FontStyle.italic,
fontSize: 16,
fontFamily: "roboto"
),
),
TextSpan(
text: " \"",
style: TextStyle(
color: Colors.black87,
fontSize: 24,
fontFamily: "roboto"
)
),
],
),
),
),
],
),
);
}
Widget cardWidget(Phrase phrase) {
return Card(
child: ListTile(
leading: ClipOval(
child: Image.network(
phrase.character.avatarUrl,
fit: BoxFit.cover,
width: 40.0,
height: 40.0,
),
),
title: Text("${phrase.character.name}"),
subtitle: Text("${phrase.content}"),
),
);
}
class Phrase {
Character character;
String content;
Phrase(this.character, this.content);
}
class Character {
String name;
String avatarUrl;
Character(this.name, this.avatarUrl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment