You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

92 lines
2.8 KiB

import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:teso/Classes/Firebase/Posts.dart';
import 'package:teso/Classes/Uploading.dart';
import 'package:teso/Pages/PageWidgets/Posts/user_posted.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:teso/Pages/PageWidgets/Uploads/Pending.dart';
import 'package:teso/Pages/Sub_Pages/@Generic/Camera/Video/RecordVideo.dart';
import 'package:teso/providers/user_provider.dart';
import 'package:teso/Pages/PageWidgets/Personal/Empty.dart';
class Posts extends StatefulWidget {
@override
_PostsState createState() => _PostsState();
}
class _PostsState extends State<Posts> {
// ScrollController _controller;
List<FBPosts> trends = <FBPosts>[];
List<FBPosts> show = <FBPosts>[];
int count;
Uint8List thumbnail;
SharedPreferences prefs;
bool loading = false;
void postContent(context) async {
await Navigator.of(context).push(
PageRouteBuilder(
opaque: false,
pageBuilder: (_, __, ___) => RecordVideo(),
),
);
}
@override
Widget build(BuildContext context) {
return Consumer<UserProvider>(
builder: (context, UserProvider value, child) {
if (value.posts == null || value.posts.isEmpty) {
return buildEmpty(context, postContent);
} else {
return StaggeredGridView.count(
crossAxisCount: 3,
children: List.generate(value.posts.length, (int index) {
// if (index == 0 && provider.isNotEmpty) {
return buildPosted(context, value.posts.elementAt(index), 0.325);
// }else{
// return buildPosted(
// context, value.posts.elementAt(index), 0.325);
// }
}),
staggeredTiles: List.generate(
value.posts.length,
(int index) {
return StaggeredTile.fit(1);
},
),
);
}
},
);
// : Center(
// child: CupertinoActivityIndicator(
// animating: true,
// radius: 15,
// ),
// );
}
Widget getTiles(BuildContext context, value) {
try {
List<Uploading> provider = value.getPending();
if (value.pending != null) {
return SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: ListView(
children: provider
.map<Widget>((item) => uploadTile(context, item))
.toList()),
);
} else {
return Container();
}
} catch (e) {
return Container();
}
}
}