Skip to content

Commit

Permalink
feat: add loading indicator for posting
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-Roshan-lab committed Aug 19, 2024
1 parent 20df1ff commit f6f822e
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 208 deletions.
6 changes: 3 additions & 3 deletions lib/pages/feed/feed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ class _FeedState extends State<Feed> with TickerProviderStateMixin {
AssetImage assetImage = el[txt]!;
return GestureDetector(
onTap: () async {
setState(() {
selectedIndex = index;
});
if (index == 0) {
await getAllPosts();
} else {
await queryCollegeInPosts(
el.keys.toList()[index]);
}
setState(() {
selectedIndex = index;
});
},
child: Container(
width: MediaQuery.of(context).size.width *
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:readmore/readmore.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:srm_curious_bug/pages/profile.dart';
import 'package:srm_curious_bug/utils/constants.dart';
import 'package:srm_curious_bug/widgets/appbar.dart';
import 'package:srm_curious_bug/widgets/gantt_chart.dart';
import 'package:srm_curious_bug/widgets/post_dialog.dart';
import 'package:url_launcher/url_launcher.dart';
Expand Down Expand Up @@ -192,7 +193,7 @@ class _PostPageState extends State<PostPage> with TickerProviderStateMixin {
TabController tabController = TabController(length: 2, vsync: this);

return Scaffold(
// appBar: appBar(context),
appBar: appBar(context),
backgroundColor: const Color(0xffF7F9FA),
body: SafeArea(
child: Column(
Expand Down
3 changes: 2 additions & 1 deletion lib/pages/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:readmore/readmore.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:srm_curious_bug/pages/post_page.dart';
import 'package:srm_curious_bug/widgets/appbar.dart';
import 'package:srm_curious_bug/widgets/editProfile.dart';
import 'package:srm_curious_bug/widgets/post_dialog.dart';
import 'package:url_launcher/url_launcher.dart';
Expand Down Expand Up @@ -146,7 +147,7 @@ class _ProfileState extends State<Profile> {
@override
Widget build(BuildContext context) {
return Scaffold(
// appBar: appBar(context),
appBar: appBar(context),
backgroundColor: const Color.fromARGB(255, 223, 218, 218),
body: SingleChildScrollView(
child: Column(
Expand Down
322 changes: 142 additions & 180 deletions lib/widgets/appbar.dart
Original file line number Diff line number Diff line change
@@ -1,181 +1,143 @@
// import 'dart:convert';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:srm_curious_bug/pages/profile.dart';

// import 'package:firebase_auth/firebase_auth.dart';
// import 'package:flutter/material.dart';
// import 'package:google_fonts/google_fonts.dart';
// import 'package:http/http.dart' as http;
// import 'package:srm_curious_bug/pages/profile.dart';
// import 'package:srm_curious_bug/widgets/post_dialog.dart';

// PreferredSizeWidget appBar(BuildContext context) {
// TextEditingController searchController = TextEditingController();
// String url = "http://10.9.31.214:80";
// final List<String> filterNames = [
// 'Hashtags',
// 'Posts',
// ];
// return AppBar(
// elevation: 0,
// leading: InkWell(
// onTap: () {
// Navigator.pushReplacementNamed(context, '/feed');
// },
// child: Padding(
// padding: const EdgeInsets.only(left: 10.0),
// child: Container(
// decoration: const BoxDecoration(
// image:
// DecorationImage(image: AssetImage("assets/images/logo.png"))),
// ),
// ),
// ),
// centerTitle: true,
// title: SizedBox(
// height: 40,
// width: MediaQuery.of(context).size.width * 0.45,
// child: TextFormField(
// controller: searchController,
// decoration: InputDecoration(
// prefixIcon: const Icon(Icons.search),
// labelText: "Search",
// suffixIcon: SizedBox(
// width: 140,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Padding(
// padding: const EdgeInsets.all(2.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// // Icon(Icons.sort,
// // color: Theme.of(context).colorScheme.primary),
// DropdownButtonHideUnderline(
// child: DropdownButton<String>(
// icon: Padding(
// padding: const EdgeInsets.only(left: 1),
// child: Icon(Icons.sort,
// color:
// Theme.of(context).colorScheme.secondary),
// ),
// iconSize: 20,
// elevation: 10,
// style: GoogleFonts.inter(
// textStyle:
// const TextStyle(color: Colors.black)),
// dropdownColor: Colors.grey[200],
// hint: Text('filter',
// style: GoogleFonts.inter(
// textStyle: TextStyle(
// fontWeight: FontWeight.w500,
// color: Theme.of(context)
// .colorScheme
// .secondary),
// )),
// value: null, // Initially selected value or null
// onChanged: (String? newValue) {
// // Handle dropdown value change
// },
// items: filterNames.map((String value) {
// return DropdownMenuItem<String>(
// value: value,
// child: Text(
// value,
// style: GoogleFonts.inter(
// textStyle: const TextStyle(fontSize: 16)),
// ),
// );
// }).toList(),
// ),
// ),
// ]),
// ),
// IconButton(
// onPressed: () async {
// http.Response res = await http.post(
// Uri.parse("$url/post"),
// body: jsonEncode({
// "user_id": "123",
// "type": "search",
// "content": searchController.text,
// "id": ""
// }));
// //TODO: implement posts list update
// },
// icon: Icon(
// Icons.search,
// color: Theme.of(context).colorScheme.primary,
// ))
// ],
// ),
// ),
// contentPadding:
// const EdgeInsets.symmetric(vertical: 8.0, horizontal: 12.0),
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(5.0),
// borderSide: const BorderSide(color: Colors.transparent, width: 0),
// ),
// enabledBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(5.0),
// borderSide: const BorderSide(color: Colors.transparent, width: 0),
// ),
// fillColor: Colors.grey.shade200,
// filled: true,
// ),
// ),
// ),
// actions: [
// TextButton(
// onPressed: () {
// postDialog(context);
// },
// style: ButtonStyle(
// backgroundColor: WidgetStateProperty.all(Colors.black),
// shape: WidgetStateProperty.all(RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(10))),
// fixedSize: WidgetStateProperty.all(const Size(100, 30))),
// child: Text(
// "Create +",
// style: GoogleFonts.inter(
// color: Colors.white, fontWeight: FontWeight.bold),
// ),
// ),
// const SizedBox(width: 20),
// InkWell(
// onTap: () {},
// child: Image.asset("assets/icons/bell.png", height: 30, width: 30),
// ),
// const SizedBox(width: 20),
// InkWell(
// onTap: () {},
// child: Image.asset("assets/icons/message.png", height: 30, width: 30),
// ),
// const SizedBox(width: 20),
// InkWell(
// onTap: () {
// Navigator.push(context, MaterialPageRoute(builder: (context) => const Profile(email: "123")));
// // Navigator.pushNamed(context, '/profile');
// },
// child: Row(
// children: [
// CircleAvatar(
// backgroundColor: Colors.white,
// radius: 18,
// backgroundImage:
// NetworkImage(FirebaseAuth.instance.currentUser!.photoURL!)),
// const SizedBox(
// height: 30,
// width: 30,
// child: Icon(
// Icons.arrow_drop_down_outlined,
// color: Colors.grey,
// ),
// )
// ],
// ),
// ),
// ],
// );
// }
PreferredSizeWidget appBar(BuildContext context) {
// TextEditingController searchController = TextEditingController();
return AppBar(
elevation: 0,
leading: InkWell(
onTap: () {
Navigator.pushReplacementNamed(context, '/feed');
},
child: Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Container(
decoration: const BoxDecoration(
image:
DecorationImage(image: AssetImage("assets/images/logo.png"))),
),
),
),
centerTitle: true,
// title: SizedBox(
// height: 40,
// width: MediaQuery.of(context).size.width * 0.45,
// child: TextFormField(
// controller: searchController,
// decoration: InputDecoration(
// prefixIcon: const Icon(Icons.search),
// labelText: "Search",
// suffixIcon: SizedBox(
// width: 140,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Padding(
// padding: const EdgeInsets.all(2.0),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// // Icon(Icons.sort,
// // color: Theme.of(context).colorScheme.primary),
// DropdownButtonHideUnderline(
// child: DropdownButton<String>(
// icon: Padding(
// padding: const EdgeInsets.only(left: 1),
// child: Icon(Icons.sort,
// color:
// Theme.of(context).colorScheme.secondary),
// ),
// iconSize: 20,
// elevation: 10,
// style: GoogleFonts.inter(
// textStyle:
// const TextStyle(color: Colors.black)),
// dropdownColor: Colors.grey[200],
// hint: Text('filter',
// style: GoogleFonts.inter(
// textStyle: TextStyle(
// fontWeight: FontWeight.w500,
// color: Theme.of(context)
// .colorScheme
// .secondary),
// )),
// value: null, // Initially selected value or null
// onChanged: (String? newValue) {
// // Handle dropdown value change
// },
// items: filterNames.map((String value) {
// return DropdownMenuItem<String>(
// value: value,
// child: Text(
// value,
// style: GoogleFonts.inter(
// textStyle: const TextStyle(fontSize: 16)),
// ),
// );
// }).toList(),
// ),
// ),
// ]),
// ),
// IconButton(
// onPressed: () async {
// http.Response res = await http.post(
// Uri.parse("$url/post"),
// body: jsonEncode({
// "user_id": "123",
// "type": "search",
// "content": searchController.text,
// "id": ""
// }));
// },
// icon: Icon(
// Icons.search,
// color: Theme.of(context).colorScheme.primary,
// ))
// ],
// ),
// ),
// contentPadding:
// const EdgeInsets.symmetric(vertical: 8.0, horizontal: 12.0),
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(5.0),
// borderSide: const BorderSide(color: Colors.transparent, width: 0),
// ),
// enabledBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(5.0),
// borderSide: const BorderSide(color: Colors.transparent, width: 0),
// ),
// fillColor: Colors.grey.shade200,
// filled: true,
// ),
// ),
// ),
actions: [
InkWell(
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context) => const Profile()));
},
child: Row(
children: [
CircleAvatar(
backgroundColor: Colors.white,
radius: 18,
backgroundImage:
NetworkImage(FirebaseAuth.instance.currentUser!.photoURL!)),
const SizedBox(
height: 30,
width: 30,
child: Icon(
Icons.arrow_drop_down_outlined,
color: Colors.grey,
),
)
],
),
),
],
);
}
Loading

0 comments on commit f6f822e

Please sign in to comment.