Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AfterHero extends StatefulWidget {
- const AfterHero(this.data, this.user, this.post);
- final DocumentSnapshot data;
- final FirebaseUser user;
- final DocumentSnapshot post;
- @override
- _AfterHeroState createState() => _AfterHeroState();
- }
- class _AfterHeroState extends State<AfterHero> {
- @override
- Widget build(BuildContext context) {
- return Hero(
- tag: widget.post["kind"],
- child: Scaffold(
- backgroundColor: Colors.teal,
- appBar: AppBar(
- title: Text(
- widget.post["kind"],
- style: TextStyle(fontFamily: 'Mono', fontSize: 20.0),
- ),
- centerTitle: true,
- titleSpacing: 0.0,
- backgroundColor: Colors.teal,
- textTheme: TextTheme(title: TextStyle(color: Colors.white)),
- ),
- body: StreamBuilder(
- stream: Firestore.instance
- .collection('TranquiDB')
- .where("condo", isEqualTo: widget.data["condo"])
- .snapshots(),
- builder:
- (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
- if (snapshot.hasError) return new Text('${snapshot.error}');
- switch (snapshot.connectionState) {
- case ConnectionState.waiting:
- return new Center(
- child: CircularProgressIndicator(),
- );
- default:
- final accounts = snapshot.data.documents;
- if (accounts.isEmpty) {
- return Container(
- child: Center(
- child: Text(
- "No hay Usuarios a quien notificar sobre ${widget.post["kind"]}",
- style: TextStyle(
- color: Colors.white.withOpacity(0.8),
- fontSize: 30.0,
- ),
- textAlign: TextAlign.center,
- ),
- ),
- );
- } else {
- List<DocumentSnapshot> wantedAccounts=[];
- accounts.forEach((acc){
- print(acc["nombreParaMostrar"]);
- if (widget.post["destinatarios"].contains(acc["perfil"])) {
- wantedAccounts.add(acc);
- }
- });
- print(wantedAccounts);
- return new ListView.builder(
- reverse: false,
- itemCount: wantedAccounts.length,
- scrollDirection: Axis.vertical,
- itemBuilder: (BuildContext context, int index) {
- var acc = wantedAccounts[index];
- return Hero(
- tag: acc["nombreParaMostrar"],
- child: Card(
- elevation: 10.0,
- color: Colors.white,
- child: ListTile(
- leading: Icon(Icons.arrow_forward_ios),
- title: Text(acc["nombreParaMostrar"]),
- subtitle: Text('Presionar para Notificar.'),
- onTap: () {
- Navigator.push(
- context,
- new MaterialPageRoute(
- builder: (context) => AfterHeroUser(
- widget.data, widget.user, widget.post, acc)));
- },
- ),
- ),
- );
- });
- }
- }
- }),
- )
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement