Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import 'package:bloc_pattern/bloc_pattern.dart';
import 'package:flutter/material.dart';
import 'package:minhacidade/domain/cidade_domain.dart';
import 'package:minhacidade/main.dart';
import 'package:transparent_image/transparent_image.dart';
import 'package:minhacidade/blocs/cidade_bloc.dart';
class CidadeDetailPage extends StatefulWidget {
final Cidade cidadeDetail;
const CidadeDetailPage({Key key, this.cidadeDetail}) : super(key: key);
@override
_CidadeDetailPageState createState() => _CidadeDetailPageState();
}
class _CidadeDetailPageState extends State<CidadeDetailPage>
with TickerProviderStateMixin {
// Configurando a animação
AnimationController _swipeUpController;
Cidade _cidade = Cidade();
final _cidadeBloc = BlocProvider.getBloc<CidadeBloc>();
@override
void initState() {
super.initState();
_cidade = widget.cidadeDetail;
_swipeUpController =
AnimationController(duration: Duration(milliseconds: 600), vsync: this)
..addListener(() {
setState(() {});
});
// _swipeUpController.forward();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
child: Stack(
children: <Widget>[
Column(
children: <Widget>[
_imageFade(context, _cidade.fotoApresentacao),
],
),
_imageMask(context),
_cardContent(context),
_arrowBack(context)
],
),
),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.check),
onPressed: () {
_cidadeBloc.setCidadeEscolhida(_cidade);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MyHomePage(
title: "tôChegando",
)));
},
),
);
}
_imageFade(context, imagem) {
return Container(
child: Hero(
tag: 'cidadeImage${_cidade.id}',
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: imagem,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
fit: BoxFit.cover,
),
));
}
_imageMask(context) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.1, 0.3],
colors: [Colors.black38, Colors.black12])),
height: MediaQuery.of(context).size.height / 2,
);
}
_cardContent(context) {
return Positioned(
top: MediaQuery.of(context).size.height - 180,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Center(
child: Opacity(
opacity: 0.94,
child: Card(
color: Colors.white,
elevation: 4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20))),
child: SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width - 22,
height: MediaQuery.of(context).size.height + 150,
child: Padding(
padding: const EdgeInsets.all(22.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"${_cidade.nome}",
style: Theme.of(context)
.textTheme
.title
.copyWith(fontSize: 32)
.copyWith(color: Colors.black54),
),
Padding(
padding: const EdgeInsets.only(top: 18.0, left: 8.0),
child: Text(
_cidade.apresentacaoPlaintext,
style: Theme.of(context)
.textTheme
.display4
.copyWith(fontSize: 16)
.copyWith(color: Colors.black45),
),
),
],
),
),
),
),
),
),
),
);
}
_arrowBack(context) {
return Positioned(
top: 30,
left: 0,
child: Container(
child: IconButton(
onPressed: () => Navigator.pop(context),
icon: Icon(
Icons.arrow_back_ios,
color: Colors.white,
),
tooltip: "Voltar para página de eventos",
)),
);
}
}
class AnimatedContent extends AnimatedWidget {
AnimatedContent(Animation<double> animation) : super(listenable: animation);
@override
Widget build(BuildContext context) {
final Animation<double> _animation = listenable;
return Center(
child: Container(
height: _animation.value,
width: _animation.value,
child: FlutterLogo(),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.