From 880b26c42d95a607e7852d55f978cf6e252cc38b Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Tue, 2 Jan 2024 15:21:46 +0530 Subject: [PATCH 01/13] centered monthly leaderboards --- .../leaderboards/monthly_leaderboard.dart | 418 +++++++++--------- 1 file changed, 213 insertions(+), 205 deletions(-) diff --git a/lib/src/pages/leaderboards/monthly_leaderboard.dart b/lib/src/pages/leaderboards/monthly_leaderboard.dart index 1f8ae67df0..7c23fd4fe4 100644 --- a/lib/src/pages/leaderboards/monthly_leaderboard.dart +++ b/lib/src/pages/leaderboards/monthly_leaderboard.dart @@ -5,6 +5,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../models/leader_model.dart'; import '../../constants/monthname_constants.dart'; + /// Page showing the top contributing users for the current month. class MonthlyLeaderBoardPage extends ConsumerStatefulWidget { const MonthlyLeaderBoardPage({Key? key}) : super(key: key); @@ -15,9 +16,10 @@ class MonthlyLeaderBoardPage extends ConsumerStatefulWidget { ScrollController _scrollController = new ScrollController(); -class _MonthlyLeaderBoardPageState extends ConsumerState { +class _MonthlyLeaderBoardPageState + extends ConsumerState { late String? paginatedUrl; - late int monthActive ; + late int monthActive; CircleAvatar buildAvatar(String partUrl) { try { if (partUrl == "") @@ -32,8 +34,8 @@ class _MonthlyLeaderBoardPageState extends ConsumerState ); else return CircleAvatar( - foregroundImage: - CachedNetworkImageProvider("https://bhfiles.storage.googleapis.com/" + partUrl), + foregroundImage: CachedNetworkImageProvider( + "https://bhfiles.storage.googleapis.com/" + partUrl), radius: 20, ); } on Exception { @@ -59,235 +61,241 @@ class _MonthlyLeaderBoardPageState extends ConsumerState }); monthActive = DateTime.now().month; super.initState(); - } void loadMoreLeaders() { paginatedUrl = ref.watch(monthlyLeaderBoardProvider.notifier).nextUrl; - if(paginatedUrl!.isNotEmpty){ + if (paginatedUrl!.isNotEmpty) { ref.watch(monthlyLeaderBoardProvider.notifier).getMoreMontlyLeaders(); } } - @override Widget build(BuildContext context) { final Size size = MediaQuery.of(context).size; final monthlyLeadersState = ref.watch(monthlyLeaderBoardProvider); return WillPopScope( - onWillPop: () async{ - ref.watch(monthlyLeaderBoardProvider.notifier).refreshMonthlyLeaderList(DateTime.now().year,DateTime.now().month); - return true; - }, - child : Scaffold( - appBar: AppBar( - leading: IconButton( - icon: Icon( - Icons.arrow_back_ios_new_rounded, + onWillPop: () async { + ref + .watch(monthlyLeaderBoardProvider.notifier) + .refreshMonthlyLeaderList( + DateTime.now().year, DateTime.now().month); + return true; + }, + child: Scaffold( + appBar: AppBar( + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios_new_rounded, + ), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + title: Text("Monthly Leaderboard"), + backgroundColor: Color(0xFFDC4654), ), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - title: Text("Monthly Leaderboard"), - backgroundColor: Color(0xFFDC4654), - ), - body: SingleChildScrollView( - child: Column( - children: [ - Container( - padding: EdgeInsets.symmetric(horizontal: 20), - width: size.width, - color: Theme.of(context).canvasColor, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: EdgeInsets.fromLTRB(0, 12, 0, 12), - child: Text( - 'Monthly Leaderboards', - style: GoogleFonts.ubuntu( - textStyle: TextStyle( - color: Color(0xFF737373), - fontSize: 25, - ), - ), - ), - ), - Container( - padding: EdgeInsets.fromLTRB(0, 0, 0, 16), - child: Column( - - children: [ Text( - "These are the most active users on BLT in", - style: GoogleFonts.aBeeZee( - textStyle: TextStyle( - color: Color(0xFF737373), + body: SingleChildScrollView( + child: Column( + children: [ + Container( + padding: EdgeInsets.symmetric(horizontal: 20), + width: size.width, + color: Theme.of(context).canvasColor, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + padding: EdgeInsets.fromLTRB(0, 12, 0, 12), + child: Text( + 'Monthly Leaderboards', + style: GoogleFonts.ubuntu( + textStyle: TextStyle( + color: Color(0xFF737373), + fontSize: 25, + ), + ), ), ), - ), - TextButton.icon( - onPressed: (){ - showModalBottomSheet( - context: context, - isScrollControlled: true, - constraints: BoxConstraints( - maxHeight: 250, - ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(10), - ) + Container( + padding: EdgeInsets.fromLTRB(0, 0, 0, 16), + child: Column(children: [ + Text( + "These are the most active users on BLT in", + style: GoogleFonts.aBeeZee( + textStyle: TextStyle( + color: Color(0xFF737373), + ), + ), ), - builder: (BuildContext context){ - return - Container( - height: 250, - alignment: Alignment.bottomCenter, - child : ListView.builder( - itemCount: DateTime.now().month, - itemBuilder: (context,index){ - return ListTile( - onTap: (){ - ref.watch(monthlyLeaderBoardProvider.notifier).refreshMonthlyLeaderList(DateTime.now().year,index+1); - setState(() { - monthActive = index+1; - }); - Navigator.pop(context); - }, - tileColor: Color(0xFFECECEC).withOpacity(0.42), - title: Text( - "${monthsInYear[index+1]}", - style: GoogleFonts.ubuntu( - textStyle: TextStyle( - color: Color(0xFF737373), - ), - ), - )); - },)); - }, - ); - }, - icon: Icon( - Icons.calendar_month, - color: Colors.white, - ), - label: Text( - "${monthsInYear[monthActive]}", - style: GoogleFonts.aBeeZee( - textStyle: TextStyle( - color: Colors.white, - fontSize: 15, + SizedBox(height: 10), + TextButton.icon( + onPressed: () { + showModalBottomSheet( + context: context, + isScrollControlled: true, + constraints: BoxConstraints( + maxHeight: 250, ), - ), - ), - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Color(0xFFDC4654)), - ), - ), - ] - ),) - ], - ), - ), - Container( - height: size.height * 0.8, - padding: EdgeInsets.symmetric(horizontal: 20), - child: monthlyLeadersState!.when( - data: (List? leaderList){ - if(leaderList!.isEmpty){ - return Center( - child: Text( - "Looks Like There isn't any activity in this month .", - textAlign: TextAlign.center, - ), - ); - }else{ - final list = leaderList; - return Padding( - padding: const EdgeInsets.symmetric( - horizontal: 0.0, - vertical: 20.0, - ), - child: Material( - color: Colors.transparent, - child: ListView.builder( - controller: _scrollController, - itemCount: list.length, - itemBuilder: (context, index) { - return ListTile( - onTap: () {}, shape: RoundedRectangleBorder( - borderRadius: index == 0 - ? BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(15), - ) - : index == list.length - 1 - ? BorderRadius.only( - bottomLeft: Radius.circular(10), - bottomRight: Radius.circular(10), - ) - : BorderRadius.only( - topLeft: Radius.circular(0), - ), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(10), + )), + builder: (BuildContext context) { + return Container( + height: 250, + alignment: Alignment.bottomCenter, + child: ListView.builder( + itemCount: DateTime.now().month, + itemBuilder: (context, index) { + return ListTile( + onTap: () { + ref + .watch( + monthlyLeaderBoardProvider + .notifier) + .refreshMonthlyLeaderList( + DateTime.now().year, + index + 1); + setState(() { + monthActive = index + 1; + }); + Navigator.pop(context); + }, + tileColor: Color(0xFFECECEC) + .withOpacity(0.42), + title: Text( + "${monthsInYear[index + 1]}", + style: GoogleFonts.ubuntu( + textStyle: TextStyle( + color: Color(0xFF737373), + ), + ), + )); + }, + )); + }, + ); + }, + icon: Icon( + Icons.calendar_month, + color: Colors.white, + ), + label: Text( + "${monthsInYear[monthActive]}", + style: GoogleFonts.aBeeZee( + textStyle: TextStyle( + color: Colors.white, + fontSize: 15, ), - tileColor: Color(0xFFECECEC).withOpacity(0.42), - leading: buildAvatar(list[index].image), - title: Text( - list[index].user, - style: GoogleFonts.ubuntu( - textStyle: TextStyle( - color: Color(0xFFDC4654), + ), + ), + style: ButtonStyle( + backgroundColor: + MaterialStateProperty.all(Color(0xFFDC4654)), + ), + ), + ]), + ) + ], + ), + ), + Container( + height: size.height * 0.8, + padding: EdgeInsets.symmetric(horizontal: 20), + child: monthlyLeadersState!.when( + data: (List? leaderList) { + if (leaderList!.isEmpty) { + return Center( + child: Text( + "Looks Like There isn't any activity in this month .", + textAlign: TextAlign.center, + ), + ); + } else { + final list = leaderList; + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 0.0, + vertical: 20.0, + ), + child: Material( + color: Colors.transparent, + child: ListView.builder( + controller: _scrollController, + itemCount: list.length, + itemBuilder: (context, index) { + return ListTile( + onTap: () {}, + shape: RoundedRectangleBorder( + borderRadius: index == 0 + ? BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(15), + ) + : index == list.length - 1 + ? BorderRadius.only( + bottomLeft: Radius.circular(10), + bottomRight: + Radius.circular(10), + ) + : BorderRadius.only( + topLeft: Radius.circular(0), + ), + ), + tileColor: + Color(0xFFECECEC).withOpacity(0.42), + leading: buildAvatar(list[index].image), + title: Text( + list[index].user, + style: GoogleFonts.ubuntu( + textStyle: TextStyle( + color: Color(0xFFDC4654), + ), ), + maxLines: 6, ), - maxLines: 6, - ), - subtitle: Text( - list[index].score.toString() + " points", - style: GoogleFonts.aBeeZee( - textStyle: TextStyle( - color: Color(0xFF737373), - fontSize: 12, + subtitle: Text( + list[index].score.toString() + " points", + style: GoogleFonts.aBeeZee( + textStyle: TextStyle( + color: Color(0xFF737373), + fontSize: 12, + ), ), ), - ), - trailing: Text( - "# " + (index + 1).toString(), - style: GoogleFonts.ubuntu( - textStyle: TextStyle( - color: Color(0xFF737373), - fontSize: 15, - fontWeight: FontWeight.bold, + trailing: Text( + "# " + (index + 1).toString(), + style: GoogleFonts.ubuntu( + textStyle: TextStyle( + color: Color(0xFF737373), + fontSize: 15, + fontWeight: FontWeight.bold, + ), ), ), - ), - ); - }, + ); + }, + ), ), + ); + } + }, error: (Object error, StackTrace? stackTrace) { + return Center( + child: Text( + 'Something went wrong!', + style: TextStyle(fontSize: 18), ), ); - } - }, - error: (Object error, StackTrace? stackTrace) { - return Center( - child: Text( - 'Something went wrong!', - style: TextStyle(fontSize: 18), - ), - ); - }, - loading: (){ - return Center( - child: CircularProgressIndicator(), - ); - } - ) - ) - ], - ), - ), - )); + }, loading: () { + return Center( + child: CircularProgressIndicator(), + ); + })) + ], + ), + ), + )); } } From 5313e9123d885fce98102639ac0017d4b4eea4f6 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Wed, 3 Jan 2024 20:14:10 +0530 Subject: [PATCH 02/13] monthly leaderboards alignment solved --- .../leaderboards/monthly_leaderboard.dart | 156 +++++++++--------- 1 file changed, 81 insertions(+), 75 deletions(-) diff --git a/lib/src/pages/leaderboards/monthly_leaderboard.dart b/lib/src/pages/leaderboards/monthly_leaderboard.dart index 7c23fd4fe4..b12eaf3322 100644 --- a/lib/src/pages/leaderboards/monthly_leaderboard.dart +++ b/lib/src/pages/leaderboards/monthly_leaderboard.dart @@ -103,7 +103,7 @@ class _MonthlyLeaderBoardPageState width: size.width, color: Theme.of(context).canvasColor, child: Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: EdgeInsets.fromLTRB(0, 12, 0, 12), @@ -119,84 +119,90 @@ class _MonthlyLeaderBoardPageState ), Container( padding: EdgeInsets.fromLTRB(0, 0, 0, 16), - child: Column(children: [ - Text( - "These are the most active users on BLT in", - style: GoogleFonts.aBeeZee( - textStyle: TextStyle( - color: Color(0xFF737373), - ), - ), - ), - SizedBox(height: 10), - TextButton.icon( - onPressed: () { - showModalBottomSheet( - context: context, - isScrollControlled: true, - constraints: BoxConstraints( - maxHeight: 250, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "These are the most active users on BLT in", + style: GoogleFonts.aBeeZee( + textStyle: TextStyle( + color: Color(0xFF737373), + ), ), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(10), - topRight: Radius.circular(10), - )), - builder: (BuildContext context) { - return Container( - height: 250, - alignment: Alignment.bottomCenter, - child: ListView.builder( - itemCount: DateTime.now().month, - itemBuilder: (context, index) { - return ListTile( - onTap: () { - ref - .watch( - monthlyLeaderBoardProvider - .notifier) - .refreshMonthlyLeaderList( - DateTime.now().year, - index + 1); - setState(() { - monthActive = index + 1; - }); - Navigator.pop(context); + ), + SizedBox(height: 10), + Center( + child: TextButton.icon( + onPressed: () { + showModalBottomSheet( + context: context, + isScrollControlled: true, + constraints: BoxConstraints( + maxHeight: 250, + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(10), + topRight: Radius.circular(10), + )), + builder: (BuildContext context) { + return Container( + height: 250, + alignment: Alignment.bottomCenter, + child: ListView.builder( + itemCount: DateTime.now().month, + itemBuilder: (context, index) { + return ListTile( + onTap: () { + ref + .watch( + monthlyLeaderBoardProvider + .notifier) + .refreshMonthlyLeaderList( + DateTime.now() + .year, + index + 1); + setState(() { + monthActive = index + 1; + }); + Navigator.pop(context); + }, + tileColor: Color(0xFFECECEC) + .withOpacity(0.42), + title: Text( + "${monthsInYear[index + 1]}", + style: GoogleFonts.ubuntu( + textStyle: TextStyle( + color: + Color(0xFF737373), + ), + ), + )); }, - tileColor: Color(0xFFECECEC) - .withOpacity(0.42), - title: Text( - "${monthsInYear[index + 1]}", - style: GoogleFonts.ubuntu( - textStyle: TextStyle( - color: Color(0xFF737373), - ), - ), - )); - }, - )); - }, - ); - }, - icon: Icon( - Icons.calendar_month, - color: Colors.white, - ), - label: Text( - "${monthsInYear[monthActive]}", - style: GoogleFonts.aBeeZee( - textStyle: TextStyle( - color: Colors.white, - fontSize: 15, + )); + }, + ); + }, + icon: Icon( + Icons.calendar_month, + color: Colors.white, + ), + label: Text( + "${monthsInYear[monthActive]}", + style: GoogleFonts.aBeeZee( + textStyle: TextStyle( + color: Colors.white, + fontSize: 15, + ), + ), + ), + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all( + Color(0xFFDC4654)), + ), ), ), - ), - style: ButtonStyle( - backgroundColor: - MaterialStateProperty.all(Color(0xFFDC4654)), - ), - ), - ]), + ]), ) ], ), From 0481411e585e8e40c5821ff0624b15f7ea857e20 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Thu, 11 Jan 2024 14:26:02 +0530 Subject: [PATCH 03/13] added title and description to the issues --- lib/src/components/issue_intro_card.dart | 5 ++- lib/src/models/issue_model.dart | 8 ++-- lib/src/pages/home/profile.dart | 25 +++++------ lib/src/pages/home/report_bug.dart | 31 ++++++++++--- lib/src/pages/issues/issue_detail.dart | 45 +++++++++++++++++-- lib/src/util/api/issues_api.dart | 12 +++-- lib/src/util/endpoints/general_endpoints.dart | 2 +- 7 files changed, 95 insertions(+), 33 deletions(-) diff --git a/lib/src/components/issue_intro_card.dart b/lib/src/components/issue_intro_card.dart index be4316751d..0f4fa19ea5 100644 --- a/lib/src/components/issue_intro_card.dart +++ b/lib/src/components/issue_intro_card.dart @@ -74,12 +74,13 @@ class IssueCard extends StatelessWidget { Container( padding: const EdgeInsets.only(top: 8, bottom: 12), child: Text( - issue.description.replaceAll("\n", " "), + issue.title.replaceAll("\n", " "), overflow: TextOverflow.ellipsis, softWrap: true, style: GoogleFonts.aBeeZee( textStyle: TextStyle( - fontSize: 12, + fontSize: 14, + fontWeight: FontWeight.w600, color: Color(0xFF737373), ), ), diff --git a/lib/src/models/issue_model.dart b/lib/src/models/issue_model.dart index c30650f2df..126a77c014 100644 --- a/lib/src/models/issue_model.dart +++ b/lib/src/models/issue_model.dart @@ -7,7 +7,8 @@ class Issue { final int? id; final User? user; final String url; - final String description; + final String title; + final String? description; final int? label; final bool isVerified; final int? score; @@ -47,6 +48,7 @@ class Issue { this.id, this.user, required this.url, + required this.title, required this.description, this.label, required this.isVerified, @@ -78,7 +80,8 @@ class Issue { ) : null, url: responseData["url"], - description: responseData["description"], + title: responseData["description"], + description: responseData["markdown_description"] ?? "", label: responseData["label"], isVerified: responseData["verified"], score: responseData["score"], @@ -119,4 +122,3 @@ class Issue { }; } } - diff --git a/lib/src/pages/home/profile.dart b/lib/src/pages/home/profile.dart index de653cbd27..280eefb346 100644 --- a/lib/src/pages/home/profile.dart +++ b/lib/src/pages/home/profile.dart @@ -97,9 +97,9 @@ class _UserProfileState extends ConsumerState { return ListTile( leading: Text("#${issue.id}"), title: Text( - (issue.description.length < 24) - ? issue.description - : issue.description.substring(0, 24) + "...", + (issue.title.length < 24) + ? issue.title + : issue.title.substring(0, 24) + "...", ), trailing: IssueStatusChip( issue: issue, @@ -162,9 +162,9 @@ class _UserProfileState extends ConsumerState { return ListTile( leading: Text("#${issue.id}"), title: Text( - (issue.description.length < 24) - ? issue.description - : issue.description.substring(0, 24) + "...", + (issue.title.length < 24) + ? issue.title + : issue.title.substring(0, 24) + "...", ), trailing: IssueStatusChip( issue: issue, @@ -227,9 +227,9 @@ class _UserProfileState extends ConsumerState { return ListTile( leading: Text("#${issue.id}"), title: Text( - (issue.description.length < 24) - ? issue.description - : issue.description.substring(0, 24) + "...", + (issue.title.length < 24) + ? issue.title + : issue.title.substring(0, 24) + "...", ), trailing: IssueStatusChip( issue: issue, @@ -334,7 +334,7 @@ class _UserProfileState extends ConsumerState { ), PopupMenuButton( onSelected: (String value) async { - switch(value) { + switch (value) { case 'Change picture': final ImagePicker _picker = ImagePicker(); final XFile? image = @@ -354,10 +354,7 @@ class _UserProfileState extends ConsumerState { break; case 'Change password': - Navigator.pushNamed( - context, - RouteManager.changePassword - ); + Navigator.pushNamed(context, RouteManager.changePassword); } }, itemBuilder: (BuildContext context) { diff --git a/lib/src/pages/home/report_bug.dart b/lib/src/pages/home/report_bug.dart index 0ad3cb86c4..a375acd26a 100644 --- a/lib/src/pages/home/report_bug.dart +++ b/lib/src/pages/home/report_bug.dart @@ -126,9 +126,15 @@ class _ReportFormState extends ConsumerState { end = temp; } - text = text.substring(0, start) + formatter + text.substring(start, end) + formatter + text.substring(end); + text = text.substring(0, start) + + formatter + + text.substring(start, end) + + formatter + + text.substring(end); _descriptionController.text = text; - _descriptionController.selection = TextSelection(baseOffset: start+formatter.length, extentOffset: end+formatter.length); + _descriptionController.selection = TextSelection( + baseOffset: start + formatter.length, + extentOffset: end + formatter.length); } void markdownLink() { @@ -142,9 +148,14 @@ class _ReportFormState extends ConsumerState { end = temp; } - text = text.substring(0, start) + "[" + text.substring(start, end) + "]()" + text.substring(end); + text = text.substring(0, start) + + "[" + + text.substring(start, end) + + "]()" + + text.substring(end); _descriptionController.text = text; - _descriptionController.selection = TextSelection(baseOffset: start+1, extentOffset: end+1); + _descriptionController.selection = + TextSelection(baseOffset: start + 1, extentOffset: end + 1); } void markdownNewLine(String newLineText) { @@ -158,9 +169,16 @@ class _ReportFormState extends ConsumerState { end = temp; } - text = text.substring(0, start) + "\n" + newLineText + text.substring(start, end) + "\n" + text.substring(end); + text = text.substring(0, start) + + "\n" + + newLineText + + text.substring(start, end) + + "\n" + + text.substring(end); _descriptionController.text = text; - _descriptionController.selection = TextSelection(baseOffset: start+newLineText.length+1, extentOffset: end+newLineText.length+1); + _descriptionController.selection = TextSelection( + baseOffset: start + newLineText.length + 1, + extentOffset: end + newLineText.length + 1); } void showIssueCategories(BuildContext context) { @@ -886,6 +904,7 @@ class _ReportFormState extends ConsumerState { Issue issue = Issue( user: currentUser!, url: _titleController.text, + title: _titleController.text, description: _descriptionController.text, isVerified: false, isOpen: true, diff --git a/lib/src/pages/issues/issue_detail.dart b/lib/src/pages/issues/issue_detail.dart index 40dc1e05d0..b511cc319d 100644 --- a/lib/src/pages/issues/issue_detail.dart +++ b/lib/src/pages/issues/issue_detail.dart @@ -50,6 +50,7 @@ class IssueDetailPage extends StatelessWidget { for (var i = 1; i <= issue.screenshotsLink!.length; i++) { validScreenshotIndexes.add(i); } + print(issue.description); return Scaffold( appBar: AppBar( @@ -113,7 +114,7 @@ class IssueDetailPage extends StatelessWidget { Container( padding: const EdgeInsets.symmetric(vertical: 12), child: Text( - "Description", + "Title", overflow: TextOverflow.ellipsis, softWrap: true, style: GoogleFonts.ubuntu( @@ -128,7 +129,7 @@ class IssueDetailPage extends StatelessWidget { Markdown( shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), - data: replaceImageTags(issue.description), + data: replaceImageTags(issue.title), padding: EdgeInsets.all(0), selectable: true, styleSheet: MarkdownStyleSheet.fromTheme( @@ -137,7 +138,8 @@ class IssueDetailPage extends StatelessWidget { textTheme: TextTheme( bodyMedium: GoogleFonts.aBeeZee( textStyle: TextStyle( - fontSize: 12, + fontSize: 15, + fontWeight: FontWeight.w500, color: Color(0xFF737373), ), ), @@ -145,6 +147,43 @@ class IssueDetailPage extends StatelessWidget { ), ), ), + if (issue.description != "") + Container( + padding: const EdgeInsets.symmetric(vertical: 12), + child: Text( + "Description", + overflow: TextOverflow.ellipsis, + softWrap: true, + style: GoogleFonts.ubuntu( + textStyle: TextStyle( + color: Color(0xFFDC4654), + fontSize: 17.5, + ), + fontWeight: FontWeight.bold, + ), + ), + ), + if (issue.description != "") + Markdown( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + data: replaceImageTags('${issue.description}'), + padding: EdgeInsets.all(0), + selectable: true, + styleSheet: MarkdownStyleSheet.fromTheme( + ThemeData( + fontFamily: GoogleFonts.aBeeZee().fontFamily, + textTheme: TextTheme( + bodyMedium: GoogleFonts.aBeeZee( + textStyle: TextStyle( + fontSize: 12, + color: Color(0xFF737373), + ), + ), + ), + ), + ), + ), Container( padding: const EdgeInsets.symmetric(vertical: 12), child: Text( diff --git a/lib/src/util/api/issues_api.dart b/lib/src/util/api/issues_api.dart index ab7526a7f4..a277dabde6 100644 --- a/lib/src/util/api/issues_api.dart +++ b/lib/src/util/api/issues_api.dart @@ -97,9 +97,12 @@ class IssueApiClient { "POST", Uri.parse(IssueEndPoints.issues), ); - await Future.forEach(issue.screenshotsLink!, (path) async => { - request.files.add(await http.MultipartFile.fromPath("screenshots", path)) - }); + await Future.forEach( + issue.screenshotsLink!, + (path) async => { + request.files + .add(await http.MultipartFile.fromPath("screenshots", path)) + }); var issueMap = issue.toJson(); request.headers.addAll({ "Content-Type": "multipart/form-data", @@ -116,7 +119,8 @@ class IssueApiClient { print(request.fields); response = await http.Response.fromStream(streamedresponse); - if (streamedresponse.statusCode == 201 || streamedresponse.statusCode == 200) { + if (streamedresponse.statusCode == 201 || + streamedresponse.statusCode == 200) { var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)); issue = Issue.fromJson(decodedResponse); diff --git a/lib/src/util/endpoints/general_endpoints.dart b/lib/src/util/endpoints/general_endpoints.dart index fa0a76c66f..a815c5f8dc 100644 --- a/lib/src/util/endpoints/general_endpoints.dart +++ b/lib/src/util/endpoints/general_endpoints.dart @@ -4,7 +4,7 @@ class GeneralEndPoints { static const String domain = "www.owasp.org/BLT/"; - static const String baseUrl = "https://www.owasp.org/BLT/"; + static const String baseUrl = "http://www.bugheist.com/"; static const String apiBaseUrl = baseUrl + "api/v1/"; From ab1bd596898ee5abc5b19294d432f359f2fc0429 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj <106571927+Uttkarsh-raj@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:09:28 +0530 Subject: [PATCH 04/13] Update general_endpoints.dart --- lib/src/util/endpoints/general_endpoints.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/util/endpoints/general_endpoints.dart b/lib/src/util/endpoints/general_endpoints.dart index a815c5f8dc..fa0a76c66f 100644 --- a/lib/src/util/endpoints/general_endpoints.dart +++ b/lib/src/util/endpoints/general_endpoints.dart @@ -4,7 +4,7 @@ class GeneralEndPoints { static const String domain = "www.owasp.org/BLT/"; - static const String baseUrl = "http://www.bugheist.com/"; + static const String baseUrl = "https://www.owasp.org/BLT/"; static const String apiBaseUrl = baseUrl + "api/v1/"; From 3c5f65970c4f66b9e25326b35efd623a41c85917 Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Sat, 20 Jan 2024 13:33:43 -0500 Subject: [PATCH 05/13] Update report_bug.dart making a change to trigger the workflow --- lib/src/pages/home/report_bug.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/pages/home/report_bug.dart b/lib/src/pages/home/report_bug.dart index a375acd26a..e207e0a467 100644 --- a/lib/src/pages/home/report_bug.dart +++ b/lib/src/pages/home/report_bug.dart @@ -1,6 +1,5 @@ import 'dart:io'; import 'dart:math'; -//import 'dart:typed_data'; import 'package:blt/src/util/api/general_api.dart'; import 'package:blt/src/util/endpoints/general_endpoints.dart'; From 1ece64ebcd3c1e6327de100f171d11672aa30026 Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Sat, 20 Jan 2024 14:00:55 -0500 Subject: [PATCH 06/13] Update issue_detail.dart --- lib/src/pages/issues/issue_detail.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/pages/issues/issue_detail.dart b/lib/src/pages/issues/issue_detail.dart index b511cc319d..92e61679d6 100644 --- a/lib/src/pages/issues/issue_detail.dart +++ b/lib/src/pages/issues/issue_detail.dart @@ -50,7 +50,6 @@ class IssueDetailPage extends StatelessWidget { for (var i = 1; i <= issue.screenshotsLink!.length; i++) { validScreenshotIndexes.add(i); } - print(issue.description); return Scaffold( appBar: AppBar( From e3997799c512c70e566bc024fc4b6b10a4566b31 Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:11:37 -0500 Subject: [PATCH 07/13] Update monthly_leaderboard.dart trigger build --- lib/src/pages/leaderboards/monthly_leaderboard.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/pages/leaderboards/monthly_leaderboard.dart b/lib/src/pages/leaderboards/monthly_leaderboard.dart index b12eaf3322..e07b2598ba 100644 --- a/lib/src/pages/leaderboards/monthly_leaderboard.dart +++ b/lib/src/pages/leaderboards/monthly_leaderboard.dart @@ -5,7 +5,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../models/leader_model.dart'; import '../../constants/monthname_constants.dart'; - +/// TEMP /// Page showing the top contributing users for the current month. class MonthlyLeaderBoardPage extends ConsumerStatefulWidget { const MonthlyLeaderBoardPage({Key? key}) : super(key: key); From 3a4ec8a03df9d0490719b5b87e0130dc7ab6383e Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:21:48 -0500 Subject: [PATCH 08/13] Update monthly_leaderboard.dart --- lib/src/pages/leaderboards/monthly_leaderboard.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/pages/leaderboards/monthly_leaderboard.dart b/lib/src/pages/leaderboards/monthly_leaderboard.dart index e07b2598ba..b12eaf3322 100644 --- a/lib/src/pages/leaderboards/monthly_leaderboard.dart +++ b/lib/src/pages/leaderboards/monthly_leaderboard.dart @@ -5,7 +5,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../models/leader_model.dart'; import '../../constants/monthname_constants.dart'; -/// TEMP + /// Page showing the top contributing users for the current month. class MonthlyLeaderBoardPage extends ConsumerStatefulWidget { const MonthlyLeaderBoardPage({Key? key}) : super(key: key); From ee0e140116dc93022f212228966adb74549056ff Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Thu, 1 Feb 2024 23:55:10 +0530 Subject: [PATCH 09/13] barrel imports --- lib/src/components/appbar.dart | 18 ++--- lib/src/components/components_import.dart | 22 ++++++ lib/src/components/contributor_card.dart | 16 ++--- lib/src/components/issue_intro_card.dart | 7 +- lib/src/components/issuechip.dart | 4 +- lib/src/components/issueflag.dart | 7 +- lib/src/components/issuelike.dart | 7 +- .../onboarding/components/onboard_page.dart | 6 +- .../onboarding/data/onboard_page_data.dart | 3 +- lib/src/components/onboarding/onboarding.dart | 9 +-- lib/src/components/searchbar.dart | 6 +- lib/src/pages/auth/forgot.dart | 4 +- lib/src/pages/auth/login.dart | 6 +- lib/src/pages/auth/signup.dart | 6 +- lib/src/pages/company_details.dart | 56 +++++++-------- lib/src/pages/drawer/about.dart | 25 +++---- lib/src/pages/drawer/change_password.dart | 12 ++-- lib/src/pages/drawer/company_dashboard.dart | 4 +- lib/src/pages/drawer/drawer_imports.dart | 13 ++++ lib/src/pages/drawer/legal.dart | 5 +- lib/src/pages/drawer/referral.dart | 2 +- lib/src/pages/drawer/social.dart | 6 +- lib/src/pages/error.dart | 4 +- lib/src/pages/home/feed.dart | 5 +- lib/src/pages/home/home.dart | 10 ++- lib/src/pages/home/home_imports.dart | 38 +++++++++++ lib/src/pages/home/issues.dart | 9 +-- lib/src/pages/home/leaderboard.dart | 20 ++---- lib/src/pages/home/profile.dart | 18 +---- lib/src/pages/home/report_bug.dart | 21 +----- lib/src/pages/home/start_hunt.dart | 59 +++++++--------- lib/src/pages/issues/issue_detail.dart | 8 +-- lib/src/pages/issues/issues_import.dart | 6 ++ .../leaderboards/company_scoreboard.dart | 8 +-- .../leaderboards/global_leaderboard.dart | 12 ++-- .../leaderboards/leaderboards_imports.dart | 10 +++ .../leaderboards/monthly_leaderboard.dart | 7 +- lib/src/pages/onboarding_main_page.dart | 6 +- lib/src/pages/pages_import.dart | 34 ++++++++++ lib/src/pages/welcome.dart | 17 ++--- lib/src/providers/authstate_provider.dart | 25 ++----- lib/src/providers/issuelist_provider.dart | 7 +- .../companyscoreboard_provider.dart | 5 +- .../globalleaderboard_povider.dart | 5 +- .../monthlyleaderboard_provider.dart | 68 +++++++++---------- lib/src/providers/login_provider.dart | 3 +- lib/src/providers/providers_imports.dart | 20 ++++++ lib/src/routes/routes_import.dart | 21 ++++++ lib/src/routes/routing.dart | 38 ++--------- lib/src/util/api/auth_api.dart | 19 ++---- lib/src/util/api/company_api.dart | 5 +- lib/src/util/api/general_api.dart | 3 +- lib/src/util/api/issues_api.dart | 7 +- lib/src/util/api/leaderboard_api.dart | 67 +++++++++--------- lib/src/util/api/user_api.dart | 8 +-- lib/src/util/endpoints/auth_endpoints.dart | 3 +- .../util/endpoints/leaderboard_endpoints.dart | 9 ++- lib/src/util/endpoints/user_endpoints.dart | 3 +- lib/src/util/services/shared_preferences.dart | 5 +- lib/src/util/util_import.dart | 14 ++++ 60 files changed, 413 insertions(+), 458 deletions(-) create mode 100644 lib/src/components/components_import.dart create mode 100644 lib/src/pages/drawer/drawer_imports.dart create mode 100644 lib/src/pages/home/home_imports.dart create mode 100644 lib/src/pages/issues/issues_import.dart create mode 100644 lib/src/pages/leaderboards/leaderboards_imports.dart create mode 100644 lib/src/pages/pages_import.dart create mode 100644 lib/src/providers/providers_imports.dart create mode 100644 lib/src/routes/routes_import.dart create mode 100644 lib/src/util/util_import.dart diff --git a/lib/src/components/appbar.dart b/lib/src/components/appbar.dart index 67b0e5bbb4..a9363aad21 100644 --- a/lib/src/components/appbar.dart +++ b/lib/src/components/appbar.dart @@ -1,9 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; - -import '../routes/routing.dart'; -import '../components/searchbar.dart'; -import '../global/variables.dart'; +import 'package:blt/src/components/components_import.dart'; /// The app's main Appbar AppBar buildAppBar({required BuildContext context}) { @@ -31,13 +27,11 @@ AppBar buildAppBar({required BuildContext context}) { Icons.account_circle, ), onPressed: () { - if(currentUser!.id == null){ - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: const Text("No profile Found Check Your Connection"), - ) - ); - return; + if (currentUser!.id == null) { + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: const Text("No profile Found Check Your Connection"), + )); + return; } Navigator.of(context).pushNamed( RouteManager.profilePage, diff --git a/lib/src/components/components_import.dart b/lib/src/components/components_import.dart new file mode 100644 index 0000000000..d02080324e --- /dev/null +++ b/lib/src/components/components_import.dart @@ -0,0 +1,22 @@ +export 'package:blt/src/routes/routing.dart'; +export 'package:flutter_svg/flutter_svg.dart'; +export 'package:blt/src/components/searchbar.dart'; +export 'package:blt/src/global/variables.dart'; +export 'package:cached_network_image/cached_network_image.dart'; +export 'package:flutter/services.dart'; +export 'package:google_fonts/google_fonts.dart'; +export 'package:url_launcher/url_launcher.dart'; +export '../models/issue_model.dart'; +export '../components/issuelike.dart'; +export 'package:flutter_riverpod/flutter_riverpod.dart'; +export '../providers/login_provider.dart'; +export '../util/api/issues_api.dart'; +export '../util/enums/login_type.dart'; +export '../models/issuedata_model.dart'; +export '../components/issue_intro_card.dart'; +export 'package:blt/src/pages/welcome.dart'; +export 'package:blt/src/components/onboarding/models/onboard_page_model.dart'; +export 'package:blt/src/components/onboarding/components/drawer_paint.dart'; +export 'package:blt/src/components/onboarding/components/onboard_page.dart'; +export 'package:blt/src/components/onboarding/data/onboard_page_data.dart'; +export 'package:smooth_page_indicator/smooth_page_indicator.dart'; diff --git a/lib/src/components/contributor_card.dart b/lib/src/components/contributor_card.dart index 01d1d307df..406a03ea9d 100644 --- a/lib/src/components/contributor_card.dart +++ b/lib/src/components/contributor_card.dart @@ -1,9 +1,5 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:url_launcher/url_launcher.dart'; +import 'package:blt/src/components/components_import.dart'; class ContributorCard extends StatelessWidget { final Map contributor; @@ -78,8 +74,8 @@ class ContributorCard extends StatelessWidget { tag: "image${contributor["id"]}", child: CircleAvatar( radius: 32, - backgroundImage: - CachedNetworkImageProvider(contributor["img"]!), + backgroundImage: CachedNetworkImageProvider( + contributor["img"]!), ), ), ), @@ -233,10 +229,12 @@ class ContributorCard extends StatelessWidget { ), IconButton( onPressed: () async { - await Clipboard.setData(ClipboardData(text: contributor["bch_addr"]!)); + await Clipboard.setData(ClipboardData( + text: contributor["bch_addr"]!)); ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text("Bitcoin cash address copied to clipboard!"), + content: Text( + "Bitcoin cash address copied to clipboard!"), ), ); }, diff --git a/lib/src/components/issue_intro_card.dart b/lib/src/components/issue_intro_card.dart index 0f4fa19ea5..3e76e0c3c9 100644 --- a/lib/src/components/issue_intro_card.dart +++ b/lib/src/components/issue_intro_card.dart @@ -1,10 +1,5 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; - -import '../routes/routing.dart'; -import '../models/issue_model.dart'; -import '../components/issuelike.dart'; +import 'package:blt/src/components/components_import.dart'; /// The card used to display issues in the list of issues on the Issue Page. class IssueCard extends StatelessWidget { diff --git a/lib/src/components/issuechip.dart b/lib/src/components/issuechip.dart index 22ef49cf30..af030e8755 100644 --- a/lib/src/components/issuechip.dart +++ b/lib/src/components/issuechip.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; - -import '../models/issue_model.dart'; +import 'package:blt/src/components/components_import.dart'; /// Chip that shows the open/close status of an issue. class IssueStatusChip extends StatelessWidget { diff --git a/lib/src/components/issueflag.dart b/lib/src/components/issueflag.dart index 40f359250b..d067d124ee 100644 --- a/lib/src/components/issueflag.dart +++ b/lib/src/components/issueflag.dart @@ -1,10 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -import '../models/issue_model.dart'; -import '../providers/login_provider.dart'; -import '../util/api/issues_api.dart'; -import '../util/enums/login_type.dart'; +import 'package:blt/src/components/components_import.dart'; /// Issue flags show and toggle component. class IssueFlagButton extends ConsumerStatefulWidget { diff --git a/lib/src/components/issuelike.dart b/lib/src/components/issuelike.dart index 83e03f2e8a..1fabae277a 100644 --- a/lib/src/components/issuelike.dart +++ b/lib/src/components/issuelike.dart @@ -1,10 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -import '../models/issue_model.dart'; -import '../util/api/issues_api.dart'; -import '../util/enums/login_type.dart'; -import '../providers/login_provider.dart'; +import 'package:blt/src/components/components_import.dart'; /// Issue likes show and toggle component. class IssueLikeButton extends ConsumerStatefulWidget { diff --git a/lib/src/components/onboarding/components/onboard_page.dart b/lib/src/components/onboarding/components/onboard_page.dart index 326f95be47..a9dc6e2667 100644 --- a/lib/src/components/onboarding/components/onboard_page.dart +++ b/lib/src/components/onboarding/components/onboard_page.dart @@ -1,8 +1,6 @@ +import 'package:blt/src/components/components_import.dart'; + import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import '../../../pages/welcome.dart'; -import '../models/onboard_page_model.dart'; -import 'drawer_paint.dart'; class OnboardPage extends StatefulWidget { final PageController pageController; diff --git a/lib/src/components/onboarding/data/onboard_page_data.dart b/lib/src/components/onboarding/data/onboard_page_data.dart index cf5271ad9a..8c02bbb587 100644 --- a/lib/src/components/onboarding/data/onboard_page_data.dart +++ b/lib/src/components/onboarding/data/onboard_page_data.dart @@ -1,7 +1,6 @@ +import 'package:blt/src/components/components_import.dart'; import 'package:flutter/material.dart'; -import '../models/onboard_page_model.dart'; - List onboardData = [ OnboardPageModel( Color(0xFFDC4654), diff --git a/lib/src/components/onboarding/onboarding.dart b/lib/src/components/onboarding/onboarding.dart index 09af649273..a1cfc18d98 100644 --- a/lib/src/components/onboarding/onboarding.dart +++ b/lib/src/components/onboarding/onboarding.dart @@ -1,9 +1,5 @@ +import 'package:blt/src/components/components_import.dart'; import 'package:flutter/material.dart'; -import '../../pages/welcome.dart'; -import 'components/onboard_page.dart'; -import 'package:smooth_page_indicator/smooth_page_indicator.dart'; -import 'data/onboard_page_data.dart'; -import 'models/onboard_page_model.dart'; class Onboarding extends StatefulWidget { final Map stats; @@ -20,7 +16,8 @@ class _OnboardingState extends State { @override void initState() { super.initState(); - onboardData[2].description = '${widget.stats["bugs"]} Bugs\n${widget.stats["users"]} Users\n${widget.stats["hunts"]} Hunts\n${widget.stats["domains"]} Domains'; + onboardData[2].description = + '${widget.stats["bugs"]} Bugs\n${widget.stats["users"]} Users\n${widget.stats["hunts"]} Hunts\n${widget.stats["domains"]} Domains'; } @override diff --git a/lib/src/components/searchbar.dart b/lib/src/components/searchbar.dart index 29ce7cfc2a..51a1d15f7e 100644 --- a/lib/src/components/searchbar.dart +++ b/lib/src/components/searchbar.dart @@ -1,9 +1,5 @@ +import 'package:blt/src/components/components_import.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; - -import '../util/api/issues_api.dart'; -import '../models/issuedata_model.dart'; -import '../components/issue_intro_card.dart'; /// The search bar of app for searching issues based on keyword. class BLTSearchDelegate extends SearchDelegate { diff --git a/lib/src/pages/auth/forgot.dart b/lib/src/pages/auth/forgot.dart index e7ecab9385..cb0e091711 100644 --- a/lib/src/pages/auth/forgot.dart +++ b/lib/src/pages/auth/forgot.dart @@ -1,7 +1,5 @@ -import 'package:blt/src/util/api/auth_api.dart'; +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; /// Page for initiating the process for recovering /// a user's account password. diff --git a/lib/src/pages/auth/login.dart b/lib/src/pages/auth/login.dart index 8eb5dbdbea..95a08c14f6 100644 --- a/lib/src/pages/auth/login.dart +++ b/lib/src/pages/auth/login.dart @@ -1,9 +1,5 @@ -import 'package:blt/src/providers/authstate_provider.dart'; -import 'package:blt/src/routes/routing.dart'; +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; /// The login page for the app. class LoginPage extends StatefulWidget { diff --git a/lib/src/pages/auth/signup.dart b/lib/src/pages/auth/signup.dart index 9bde05e059..cc4ded415d 100644 --- a/lib/src/pages/auth/signup.dart +++ b/lib/src/pages/auth/signup.dart @@ -1,9 +1,5 @@ -import 'package:blt/src/util/api/auth_api.dart'; +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; - -import '../../routes/routing.dart'; /// The signup page for the app. class SignUpPage extends StatefulWidget { diff --git a/lib/src/pages/company_details.dart b/lib/src/pages/company_details.dart index b2163d7029..1df301656c 100644 --- a/lib/src/pages/company_details.dart +++ b/lib/src/pages/company_details.dart @@ -1,8 +1,5 @@ -import 'package:cached_network_image/cached_network_image.dart'; +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import '../models/company_model.dart'; -import 'package:url_launcher/url_launcher.dart'; /// Popup page for viewing company details when a company /// is clicked on the Company Scoreboard page. @@ -20,42 +17,39 @@ class CompanyDetailPage extends StatefulWidget { class _CompanyDetailPageState extends State { late Color companyColor; - Future redirectEmail(BuildContext context,Company company) async{ + Future redirectEmail(BuildContext context, Company company) async { SnackBar emailSnack = SnackBar( content: Text("This company has not provided their email ."), duration: Duration(seconds: 2), - ); - if(company.email == null){ - ScaffoldMessenger.of(context).showSnackBar(emailSnack); - }else{ - String email = Uri.encodeComponent(company.email!); - Uri mail = Uri.parse("mailto:${email}"); - try { - await launchUrl(mail); - } - catch(e){} - } + ); + if (company.email == null) { + ScaffoldMessenger.of(context).showSnackBar(emailSnack); + } else { + String email = Uri.encodeComponent(company.email!); + Uri mail = Uri.parse("mailto:${email}"); + try { + await launchUrl(mail); + } catch (e) {} + } } - Future redirectSite(BuildContext context,Company company) async{ + Future redirectSite(BuildContext context, Company company) async { SnackBar siteSnack = SnackBar( content: Text("This company has not provided their site ."), duration: Duration(seconds: 2), ); - if(company.url == null){ - ScaffoldMessenger.of(context).showSnackBar(siteSnack); - } - else{ - String siteUrl = company.url!; - Uri site = Uri.parse(siteUrl); - try { - await launchUrl(site,mode: LaunchMode.externalApplication,webOnlyWindowName: company.companyName); - } - catch(e){} - - } - } - + if (company.url == null) { + ScaffoldMessenger.of(context).showSnackBar(siteSnack); + } else { + String siteUrl = company.url!; + Uri site = Uri.parse(siteUrl); + try { + await launchUrl(site, + mode: LaunchMode.externalApplication, + webOnlyWindowName: company.companyName); + } catch (e) {} + } + } Widget buildOpenIssueList(Size size) { return Container( diff --git a/lib/src/pages/drawer/about.dart b/lib/src/pages/drawer/about.dart index 4a3b32887e..86f464bd2a 100644 --- a/lib/src/pages/drawer/about.dart +++ b/lib/src/pages/drawer/about.dart @@ -1,10 +1,5 @@ -import 'package:blt/src/components/contributor_card.dart'; -import 'package:blt/src/constants/about_constants.dart'; -import 'package:blt/src/util/api/general_api.dart'; -import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; +import 'package:blt/src/pages/pages_import.dart'; /// Page for describing the BLT project. class AboutPage extends StatelessWidget { @@ -160,15 +155,12 @@ class AboutPage extends StatelessWidget { for (var contributor in snapshot.data!) { contributors.add(InkWell( onTap: () { - Navigator.of(context).push( - new PageRouteBuilder( - opaque: false, - barrierDismissible:true, - pageBuilder: (BuildContext context, _, __) { - return ContributorCard(contributor: contributor); - } - ) - ); + Navigator.of(context).push(new PageRouteBuilder( + opaque: false, + barrierDismissible: true, + pageBuilder: (BuildContext context, _, __) { + return ContributorCard(contributor: contributor); + })); }, child: Ink( child: Column( @@ -177,7 +169,8 @@ class AboutPage extends StatelessWidget { tag: "image${contributor["id"]}", child: CircleAvatar( radius: 32, - backgroundImage: CachedNetworkImageProvider(contributor["img"]!), + backgroundImage: CachedNetworkImageProvider( + contributor["img"]!), ), ), SizedBox( diff --git a/lib/src/pages/drawer/change_password.dart b/lib/src/pages/drawer/change_password.dart index b004d4d64e..55c9508828 100644 --- a/lib/src/pages/drawer/change_password.dart +++ b/lib/src/pages/drawer/change_password.dart @@ -1,9 +1,6 @@ -import 'package:blt/src/util/api/auth_api.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; -//import '../../routes/routing.dart'; +import '../pages_import.dart'; /// The change password page for the app. class ChangePasswordPage extends StatefulWidget { @@ -111,9 +108,7 @@ class ChangePasswordForm extends StatefulWidget { class _ChangePasswordFormState extends State { final _formKey = GlobalKey(); - late TextEditingController _oldController, - _new1Controller, - _new2Controller; + late TextEditingController _oldController, _new1Controller, _new2Controller; @override void initState() { @@ -223,7 +218,8 @@ class _ChangePasswordFormState extends State { child: TextButton( onPressed: () async { if (_formKey.currentState!.validate()) { - bool oldPasswordCorrect = await AuthApiClient.checkPassword(_oldController.text); + bool oldPasswordCorrect = + await AuthApiClient.checkPassword(_oldController.text); if (!oldPasswordCorrect) { SnackBar sentSnack = SnackBar( content: Text("Incorrect old password."), diff --git a/lib/src/pages/drawer/company_dashboard.dart b/lib/src/pages/drawer/company_dashboard.dart index a43806730c..3170152c56 100644 --- a/lib/src/pages/drawer/company_dashboard.dart +++ b/lib/src/pages/drawer/company_dashboard.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:google_fonts/google_fonts.dart'; + +import '../pages_import.dart'; class CompanyDashBoardPage extends ConsumerStatefulWidget { const CompanyDashBoardPage({Key? key}) : super(key: key); diff --git a/lib/src/pages/drawer/drawer_imports.dart b/lib/src/pages/drawer/drawer_imports.dart new file mode 100644 index 0000000000..cc0db9eeb8 --- /dev/null +++ b/lib/src/pages/drawer/drawer_imports.dart @@ -0,0 +1,13 @@ +export 'package:blt/src/components/contributor_card.dart'; +export 'package:blt/src/constants/about_constants.dart'; +export 'package:blt/src/util/api/general_api.dart'; +export 'package:cached_network_image/cached_network_image.dart'; +export 'package:flutter_svg/flutter_svg.dart'; +export 'package:google_fonts/google_fonts.dart'; +export 'package:blt/src/util/api/auth_api.dart'; +export 'package:flutter_riverpod/flutter_riverpod.dart'; +export 'package:flutter/services.dart'; +export 'package:flutter_markdown/flutter_markdown.dart'; +export 'package:font_awesome_flutter/font_awesome_flutter.dart'; +export 'package:url_launcher/url_launcher.dart'; +export '../../constants/socialurls_constants.dart'; diff --git a/lib/src/pages/drawer/legal.dart b/lib/src/pages/drawer/legal.dart index 05b0809b11..1febc95dca 100644 --- a/lib/src/pages/drawer/legal.dart +++ b/lib/src/pages/drawer/legal.dart @@ -1,8 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; +import '../pages_import.dart'; /// Page stating the legal Terms and Conditions and Privacy /// Policy applying to the BLT project. diff --git a/lib/src/pages/drawer/referral.dart b/lib/src/pages/drawer/referral.dart index 7cfa840c21..44d3e10f99 100644 --- a/lib/src/pages/drawer/referral.dart +++ b/lib/src/pages/drawer/referral.dart @@ -1,5 +1,5 @@ +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; /// Page for allowing users to send referrals to their friends. class ReferralPage extends StatefulWidget { diff --git a/lib/src/pages/drawer/social.dart b/lib/src/pages/drawer/social.dart index 2543cad3a1..db57ec727b 100644 --- a/lib/src/pages/drawer/social.dart +++ b/lib/src/pages/drawer/social.dart @@ -1,10 +1,6 @@ +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; //import 'package:flutter_inappwebview/flutter_inappwebview.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:url_launcher/url_launcher.dart'; -import '../../constants/socialurls_constants.dart'; class SocialPage extends ConsumerStatefulWidget { const SocialPage({Key? key}) : super(key: key); diff --git a/lib/src/pages/error.dart b/lib/src/pages/error.dart index b24f595483..0fa91981fd 100644 --- a/lib/src/pages/error.dart +++ b/lib/src/pages/error.dart @@ -1,7 +1,5 @@ -import 'package:blt/src/routes/routing.dart'; +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:flutter_svg/flutter_svg.dart'; /// This page is thrown in case when a Navigation exception occurs. class ErrorPage extends StatelessWidget { diff --git a/lib/src/pages/home/feed.dart b/lib/src/pages/home/feed.dart index ef4c9d31ec..098022b4b3 100644 --- a/lib/src/pages/home/feed.dart +++ b/lib/src/pages/home/feed.dart @@ -1,8 +1,5 @@ +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -import '../../global/variables.dart'; /// Page for showing social activity of BLT, new issues, /// top premium subscribers. diff --git a/lib/src/pages/home/home.dart b/lib/src/pages/home/home.dart index 5c7a6fb97b..da706ae2e8 100644 --- a/lib/src/pages/home/home.dart +++ b/lib/src/pages/home/home.dart @@ -207,7 +207,6 @@ class _HomeState extends ConsumerState { @override Widget build(BuildContext context) { - return WillPopScope( onWillPop: () async { showGeneralDialog( @@ -260,9 +259,8 @@ class _HomeState extends ConsumerState { // Then close the drawer await forgetUser(); await Navigator.of(context).pushAndRemoveUntil( - MaterialPageRoute( - builder: (context) => WelcomePage()), - (Route route) => false); + MaterialPageRoute(builder: (context) => WelcomePage()), + (Route route) => false); await logout(); }, ), @@ -331,8 +329,8 @@ class _HomeState extends ConsumerState { ), ), style: ButtonStyle( - shape: MaterialStateProperty.all< - RoundedRectangleBorder>( + shape: + MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(8.0), ), diff --git a/lib/src/pages/home/home_imports.dart b/lib/src/pages/home/home_imports.dart new file mode 100644 index 0000000000..50f8c80512 --- /dev/null +++ b/lib/src/pages/home/home_imports.dart @@ -0,0 +1,38 @@ +export 'package:google_fonts/google_fonts.dart'; +export 'package:flutter_riverpod/flutter_riverpod.dart'; +export '../../global/variables.dart'; +export 'package:blt/src/pages/home/issues.dart'; +export 'package:blt/src/pages/home/leaderboard.dart'; +export 'package:blt/src/pages/home/report_bug.dart'; +export 'package:blt/src/pages/home/start_hunt.dart'; +export 'package:blt/src/providers/authstate_provider.dart'; +export 'package:blt/src/providers/login_provider.dart'; +export 'package:blt/src/routes/routing.dart'; +export 'package:blt/src/util/enums/login_type.dart'; +export 'package:cached_network_image/cached_network_image.dart'; +export 'package:receive_sharing_intent/receive_sharing_intent.dart'; +export '../../components/appbar.dart'; +export '../../pages/welcome.dart'; +export 'package:blt/src/providers/issuelist_provider.dart'; +export '../../components/issue_intro_card.dart'; +export '../../models/issue_model.dart'; +export '../../util/endpoints/issue_endpoints.dart'; +export '../../constants/monthname_constants.dart'; +export '../../providers/leaderboards/globalleaderboard_povider.dart'; +export '../../providers/leaderboards/monthlyleaderboard_provider.dart'; +export '../../providers/leaderboards/companyscoreboard_provider.dart'; +export 'package:blt/src/util/api/user_api.dart'; +export 'package:image_picker/image_picker.dart'; +export '../../models/user_model.dart'; +export '../../util/api/issues_api.dart'; +export '../../components/issuechip.dart'; +export '../../models/issuedata_model.dart'; +export 'dart:io'; +export 'dart:math'; +export 'package:blt/src/util/api/general_api.dart'; +export 'package:blt/src/util/endpoints/general_endpoints.dart'; +export 'package:flutter/gestures.dart'; +export 'package:flutter_svg/flutter_svg.dart'; +export 'package:url_launcher/url_launcher.dart'; +export 'package:flutter_markdown/flutter_markdown.dart'; +export 'package:pasteboard/pasteboard.dart'; diff --git a/lib/src/pages/home/issues.dart b/lib/src/pages/home/issues.dart index 60b0b6c65a..0c0d1d8066 100644 --- a/lib/src/pages/home/issues.dart +++ b/lib/src/pages/home/issues.dart @@ -1,13 +1,6 @@ -import 'package:blt/src/providers/issuelist_provider.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:google_fonts/google_fonts.dart'; - -import '../../components/issue_intro_card.dart'; +import 'package:blt/src/pages/home/home_imports.dart'; import 'package:flutter/material.dart'; -import '../../models/issue_model.dart'; -import '../../util/endpoints/issue_endpoints.dart'; - /// Issues page for viewing all the issues posted via the website and app. class IssuesPage extends ConsumerStatefulWidget { const IssuesPage({Key? key}) : super(key: key); diff --git a/lib/src/pages/home/leaderboard.dart b/lib/src/pages/home/leaderboard.dart index 56b19dfc34..08136c1549 100644 --- a/lib/src/pages/home/leaderboard.dart +++ b/lib/src/pages/home/leaderboard.dart @@ -1,12 +1,5 @@ -import 'package:cached_network_image/cached_network_image.dart'; +import 'package:blt/src/pages/home/home_imports.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:google_fonts/google_fonts.dart'; -import '../../constants/monthname_constants.dart'; -import '../../routes/routing.dart'; -import '../../providers/leaderboards/globalleaderboard_povider.dart'; -import '../../providers/leaderboards/monthlyleaderboard_provider.dart'; -import '../../providers/leaderboards/companyscoreboard_provider.dart'; /// The Leaderboards dashboard page, contains the Global, /// Monthly leaderboard, and Company Scoreboard. @@ -42,8 +35,8 @@ class _LeaderBoardState extends ConsumerState { ); else return CircleAvatar( - foregroundImage: - CachedNetworkImageProvider("https://bhfiles.storage.googleapis.com/" + partUrl), + foregroundImage: CachedNetworkImageProvider( + "https://bhfiles.storage.googleapis.com/" + partUrl), radius: 20, ); } on Exception { @@ -319,7 +312,9 @@ class _LeaderBoardState extends ConsumerState { }, child: ListView.builder( padding: EdgeInsets.zero, - itemCount: (leaderList!.length < 3 ? leaderList.length : 3), + itemCount: (leaderList!.length < 3 + ? leaderList.length + : 3), shrinkWrap: true, itemBuilder: (context, index) { return ListTile( @@ -347,8 +342,7 @@ class _LeaderBoardState extends ConsumerState { ? Color(0xFFFFD700) .withOpacity(0.42) : Colors.white, - leading: - buildAvatar(leaderList[index].image), + leading: buildAvatar(leaderList[index].image), title: Text( leaderList[index].user, style: GoogleFonts.ubuntu( diff --git a/lib/src/pages/home/profile.dart b/lib/src/pages/home/profile.dart index 280eefb346..cf29c2fdc1 100644 --- a/lib/src/pages/home/profile.dart +++ b/lib/src/pages/home/profile.dart @@ -1,21 +1,5 @@ -import 'package:blt/src/util/api/user_api.dart'; +import 'package:blt/src/pages/home/home_imports.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:image_picker/image_picker.dart'; - -import '../../providers/login_provider.dart'; -import '../../routes/routing.dart'; -import '../../global/variables.dart'; -import '../../models/user_model.dart'; -import '../../models/issue_model.dart'; -import '../../util/api/issues_api.dart'; -import '../../components/issuechip.dart'; -import '../../providers/authstate_provider.dart'; -import '../../models/issuedata_model.dart'; -import '../../util/endpoints/issue_endpoints.dart'; -import '../../pages/welcome.dart'; -import '../../util/enums/login_type.dart'; /// Page that displays the stats of a user registered on BLT, /// shows dummy data for Guest login. diff --git a/lib/src/pages/home/report_bug.dart b/lib/src/pages/home/report_bug.dart index a375acd26a..138195e3bd 100644 --- a/lib/src/pages/home/report_bug.dart +++ b/lib/src/pages/home/report_bug.dart @@ -1,24 +1,5 @@ -import 'dart:io'; -import 'dart:math'; -//import 'dart:typed_data'; - -import 'package:blt/src/util/api/general_api.dart'; -import 'package:blt/src/util/endpoints/general_endpoints.dart'; -import 'package:flutter/gestures.dart'; +import 'package:blt/src/pages/home/home_imports.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:image_picker/image_picker.dart'; -//import 'package:pasteboard/pasteboard.dart'; -//import 'package:path_provider/path_provider.dart'; -import 'package:receive_sharing_intent/receive_sharing_intent.dart'; -import 'package:url_launcher/url_launcher.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; - -import '../../global/variables.dart'; -import '../../util/api/issues_api.dart'; -import '../../models/issue_model.dart'; /// Report Bug and Start Bug Hunt Page, namesake, used for /// posting bugs, companies and individuals diff --git a/lib/src/pages/home/start_hunt.dart b/lib/src/pages/home/start_hunt.dart index cb06e744d0..59e3b73111 100644 --- a/lib/src/pages/home/start_hunt.dart +++ b/lib/src/pages/home/start_hunt.dart @@ -1,11 +1,6 @@ -import 'dart:io'; import 'dart:typed_data'; - import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:pasteboard/pasteboard.dart'; +import 'package:blt/src/pages/home/home_imports.dart'; import 'package:path_provider/path_provider.dart'; /// Start Bug Hunt Page @@ -53,29 +48,27 @@ class _HuntFormState extends State { }); } - Future _convertToImage(Uint8List imageBytes) async{ + Future _convertToImage(Uint8List imageBytes) async { String tempPath = (await getTemporaryDirectory()).path; File file = File('$tempPath/profile.png'); - await file.writeAsBytes( - imageBytes.buffer.asUint8List(imageBytes.offsetInBytes, imageBytes.lengthInBytes)); + await file.writeAsBytes(imageBytes.buffer + .asUint8List(imageBytes.offsetInBytes, imageBytes.lengthInBytes)); return file; } - Future _pasteImageFromClipBoard() async{ + Future _pasteImageFromClipBoard() async { try { final imageBytes = await Pasteboard.image; - late File? image ; - if(imageBytes != null){ + late File? image; + if (imageBytes != null) { image = await _convertToImage(imageBytes); } setState(() { - _image = image! ; + _image = image!; }); - } - catch(e){ + } catch (e) { print('No Image Found On Clipboard'); } - } @override @@ -134,7 +127,7 @@ class _HuntFormState extends State { ), Container( margin: const EdgeInsets.symmetric(vertical: 8.0), - child:Row( + child: Row( children: [ SizedBox( child: TextButton( @@ -190,28 +183,28 @@ class _HuntFormState extends State { margin: const EdgeInsets.only(bottom: 12.0), child: _image.path == "" ? Center( - child: Text( - 'No image selected.', - style: GoogleFonts.aBeeZee( - textStyle: TextStyle( - color: Color(0xFF737373), - ), - ), - ), - ) + child: Text( + 'No image selected.', + style: GoogleFonts.aBeeZee( + textStyle: TextStyle( + color: Color(0xFF737373), + ), + ), + ), + ) : Image.file( - _image, - fit: BoxFit.cover, - ), + _image, + fit: BoxFit.cover, + ), decoration: BoxDecoration( border: _image.path == "" ? Border.all( - color: Color(0xFFDC4654), - width: 0.5, - ) + color: Color(0xFFDC4654), + width: 0.5, + ) : null, borderRadius: - _image.path == "" ? BorderRadius.circular(15) : null, + _image.path == "" ? BorderRadius.circular(15) : null, ), ), Container( diff --git a/lib/src/pages/issues/issue_detail.dart b/lib/src/pages/issues/issue_detail.dart index b511cc319d..e0bffeafa4 100644 --- a/lib/src/pages/issues/issue_detail.dart +++ b/lib/src/pages/issues/issue_detail.dart @@ -1,11 +1,5 @@ +import 'package:blt/src/pages/issues/issues_import.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:flutter_markdown/flutter_markdown.dart'; - -import '../../models/issue_model.dart'; -import '../../components/issuechip.dart'; -import '../../components/issueflag.dart'; -import '../../components/issuelike.dart'; /// Popup page when an issue is clicked to be viewed. class IssueDetailPage extends StatelessWidget { diff --git a/lib/src/pages/issues/issues_import.dart b/lib/src/pages/issues/issues_import.dart new file mode 100644 index 0000000000..dcb060cfc1 --- /dev/null +++ b/lib/src/pages/issues/issues_import.dart @@ -0,0 +1,6 @@ +export 'package:google_fonts/google_fonts.dart'; +export 'package:flutter_markdown/flutter_markdown.dart'; +export '../../models/issue_model.dart'; +export '../../components/issuechip.dart'; +export '../../components/issueflag.dart'; +export '../../components/issuelike.dart'; diff --git a/lib/src/pages/leaderboards/company_scoreboard.dart b/lib/src/pages/leaderboards/company_scoreboard.dart index 4ed2e4390b..5b515ad6dc 100644 --- a/lib/src/pages/leaderboards/company_scoreboard.dart +++ b/lib/src/pages/leaderboards/company_scoreboard.dart @@ -1,11 +1,5 @@ -import 'package:blt/src/util/endpoints/leaderboard_endpoints.dart'; -import 'package:cached_network_image/cached_network_image.dart'; +import 'package:blt/src/pages/leaderboards/leaderboards_imports.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; - -import '../../routes/routing.dart'; -import '../../util/api/company_api.dart'; -import '../../util/api/leaderboard_api.dart'; /// Page showing the top contributing companies on BLT. class CompanyScoreBoardPage extends StatefulWidget { diff --git a/lib/src/pages/leaderboards/global_leaderboard.dart b/lib/src/pages/leaderboards/global_leaderboard.dart index 39106abb76..e844430e01 100644 --- a/lib/src/pages/leaderboards/global_leaderboard.dart +++ b/lib/src/pages/leaderboards/global_leaderboard.dart @@ -1,10 +1,6 @@ -import 'dart:async'; -import 'package:cached_network_image/cached_network_image.dart'; +import 'package:blt/src/pages/leaderboards/leaderboards_imports.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; - -import '../../util/api/leaderboard_api.dart'; -import '../../util/endpoints/leaderboard_endpoints.dart'; +import 'dart:async'; /// Page showing the all time top contributing users. class GlobalLeaderBoardPage extends StatefulWidget { @@ -43,8 +39,8 @@ class _GlobalLeaderBoardPageState extends State { ); else return CircleAvatar( - foregroundImage: - CachedNetworkImageProvider("https://bhfiles.storage.googleapis.com/" + partUrl), + foregroundImage: CachedNetworkImageProvider( + "https://bhfiles.storage.googleapis.com/" + partUrl), radius: 20, ); } on Exception { diff --git a/lib/src/pages/leaderboards/leaderboards_imports.dart b/lib/src/pages/leaderboards/leaderboards_imports.dart new file mode 100644 index 0000000000..865ecb5e6c --- /dev/null +++ b/lib/src/pages/leaderboards/leaderboards_imports.dart @@ -0,0 +1,10 @@ +export 'package:blt/src/util/endpoints/leaderboard_endpoints.dart'; +export 'package:cached_network_image/cached_network_image.dart'; +export 'package:google_fonts/google_fonts.dart'; +export '../../routes/routing.dart'; +export '../../util/api/company_api.dart'; +export '../../util/api/leaderboard_api.dart'; +export 'package:blt/src/providers/leaderboards/monthlyleaderboard_provider.dart'; +export 'package:flutter_riverpod/flutter_riverpod.dart'; +export '../../models/leader_model.dart'; +export '../../constants/monthname_constants.dart'; diff --git a/lib/src/pages/leaderboards/monthly_leaderboard.dart b/lib/src/pages/leaderboards/monthly_leaderboard.dart index b12eaf3322..187b764f3c 100644 --- a/lib/src/pages/leaderboards/monthly_leaderboard.dart +++ b/lib/src/pages/leaderboards/monthly_leaderboard.dart @@ -1,10 +1,5 @@ -import 'package:blt/src/providers/leaderboards/monthlyleaderboard_provider.dart'; -import 'package:cached_network_image/cached_network_image.dart'; +import 'package:blt/src/pages/leaderboards/leaderboards_imports.dart'; import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../../models/leader_model.dart'; -import '../../constants/monthname_constants.dart'; /// Page showing the top contributing users for the current month. class MonthlyLeaderBoardPage extends ConsumerStatefulWidget { diff --git a/lib/src/pages/onboarding_main_page.dart b/lib/src/pages/onboarding_main_page.dart index d7d32181fa..f03036b08d 100644 --- a/lib/src/pages/onboarding_main_page.dart +++ b/lib/src/pages/onboarding_main_page.dart @@ -1,9 +1,5 @@ +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; -import '../components/onboarding/onboarding.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:blt/src/providers/authstate_provider.dart'; - -import '../util/api/general_api.dart'; class OnboardingMainPage extends ConsumerStatefulWidget { @override diff --git a/lib/src/pages/pages_import.dart b/lib/src/pages/pages_import.dart new file mode 100644 index 0000000000..4dc3135f3a --- /dev/null +++ b/lib/src/pages/pages_import.dart @@ -0,0 +1,34 @@ +export 'package:cached_network_image/cached_network_image.dart'; +export 'package:google_fonts/google_fonts.dart'; +export '../models/company_model.dart'; +export 'package:url_launcher/url_launcher.dart'; +export 'package:blt/src/routes/routing.dart'; +export 'package:flutter_svg/flutter_svg.dart'; +export '../components/onboarding/onboarding.dart'; +export 'package:flutter_riverpod/flutter_riverpod.dart'; +export 'package:blt/src/providers/authstate_provider.dart'; +export '../util/api/general_api.dart'; +export 'package:blt/src/util/api/auth_api.dart'; +export 'package:blt/src/constants/about_constants.dart'; +export 'package:blt/src/components/contributor_card.dart'; +export 'package:flutter/services.dart'; +export 'package:flutter_markdown/flutter_markdown.dart'; +export 'package:font_awesome_flutter/font_awesome_flutter.dart'; +export 'package:blt/src/constants/socialurls_constants.dart'; +export 'package:blt/src/pages/home/issues.dart'; +export 'package:blt/src/pages/home/leaderboard.dart'; +export 'package:blt/src/pages/home/report_bug.dart'; +export 'package:blt/src/pages/home/start_hunt.dart'; +export 'package:blt/src/providers/login_provider.dart'; +export 'package:blt/src/util/enums/login_type.dart'; +export 'package:receive_sharing_intent/receive_sharing_intent.dart'; +export 'package:blt/src/providers/issuelist_provider.dart'; +export 'package:blt/src/util/api/user_api.dart'; +export 'package:image_picker/image_picker.dart'; +export 'dart:io'; +export 'dart:math'; +export 'package:blt/src/util/endpoints/general_endpoints.dart'; +export 'package:flutter/gestures.dart'; +export 'package:pasteboard/pasteboard.dart'; +export 'package:blt/src/global/variables.dart'; +export 'package:blt/src/pages/welcome.dart'; diff --git a/lib/src/pages/welcome.dart b/lib/src/pages/welcome.dart index 0bcec74f88..7f7690dc46 100644 --- a/lib/src/pages/welcome.dart +++ b/lib/src/pages/welcome.dart @@ -1,11 +1,6 @@ -import 'package:blt/src/providers/authstate_provider.dart'; +import 'package:blt/src/pages/pages_import.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; - -import '../routes/routing.dart'; /// The Landing page for unauthenticated users, or if a /// user wants to try the guest mode of the app. @@ -117,8 +112,8 @@ class _WelcomePageState extends State { shadowColor: MaterialStateProperty.all( Colors.black.withOpacity(0.5), ), - shape: - MaterialStateProperty.all( + shape: MaterialStateProperty.all< + RoundedRectangleBorder>( RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), @@ -139,8 +134,10 @@ class _WelcomePageState extends State { builder: (BuildContext context, ref, Widget? child) { return TextButton( onPressed: () async { - await ref.read(authStateNotifier.notifier).guestLogin(); - Navigator.of(context).pushNamed( + await ref + .read(authStateNotifier.notifier) + .guestLogin(); + Navigator.of(context).pushNamed( RouteManager.homePage, ); }, diff --git a/lib/src/providers/authstate_provider.dart b/lib/src/providers/authstate_provider.dart index dc5dd674af..05161e147b 100644 --- a/lib/src/providers/authstate_provider.dart +++ b/lib/src/providers/authstate_provider.dart @@ -1,16 +1,4 @@ -import 'package:blt/src/pages/welcome.dart'; -import 'package:blt/src/util/api/user_api.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; - -import './login_provider.dart'; -import '../models/user_model.dart'; -import '../routes/routing.dart'; -import '../global/variables.dart'; -import '../util/api/auth_api.dart'; -import '../util/enums/authstate_type.dart'; -import '../util/enums/login_type.dart'; +import 'package:blt/src/providers/providers_imports.dart'; /// The provider which exposes the state management for user authentication. final authStateNotifier = @@ -39,13 +27,14 @@ class AuthNotifier extends StateNotifier> { read(loginProvider.notifier).setGuestLogin(); } - Future checkFirstLogin(BuildContext context) async{ + Future checkFirstLogin(BuildContext context) async { String? firstLogin = await storage.read(key: "firstLogin"); - if(firstLogin == null) { + if (firstLogin == null) { await storage.write(key: "firstLogin", value: "false"); - }else if(firstLogin == "false"){ - Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute( - builder: (context) => WelcomePage()), (Route route) => false); + } else if (firstLogin == "false") { + Navigator.of(context).pushAndRemoveUntil( + MaterialPageRoute(builder: (context) => WelcomePage()), + (Route route) => false); } } diff --git a/lib/src/providers/issuelist_provider.dart b/lib/src/providers/issuelist_provider.dart index f7369e9a43..c5b86103c9 100644 --- a/lib/src/providers/issuelist_provider.dart +++ b/lib/src/providers/issuelist_provider.dart @@ -1,9 +1,4 @@ -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../models/issue_model.dart'; -import '../models/issuedata_model.dart'; - -import '../util/api/issues_api.dart'; -import '../util/endpoints/issue_endpoints.dart'; +import 'package:blt/src/providers/providers_imports.dart'; /// The provider which exposes the state management /// for issues in the issue list. diff --git a/lib/src/providers/leaderboards/companyscoreboard_provider.dart b/lib/src/providers/leaderboards/companyscoreboard_provider.dart index d2b502e544..1ed0ea987d 100644 --- a/lib/src/providers/leaderboards/companyscoreboard_provider.dart +++ b/lib/src/providers/leaderboards/companyscoreboard_provider.dart @@ -1,7 +1,4 @@ -import 'package:blt/src/models/company_model.dart'; -import 'package:blt/src/util/api/leaderboard_api.dart'; -import 'package:blt/src/util/endpoints/leaderboard_endpoints.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:blt/src/providers/providers_imports.dart'; /// The provider which exposes the state management /// for companies in the company scoreboard list. diff --git a/lib/src/providers/leaderboards/globalleaderboard_povider.dart b/lib/src/providers/leaderboards/globalleaderboard_povider.dart index 25639cbbfb..e012f7d29e 100644 --- a/lib/src/providers/leaderboards/globalleaderboard_povider.dart +++ b/lib/src/providers/leaderboards/globalleaderboard_povider.dart @@ -1,7 +1,4 @@ -import 'package:blt/src/models/leader_model.dart'; -import 'package:blt/src/util/api/leaderboard_api.dart'; -import 'package:blt/src/util/endpoints/leaderboard_endpoints.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:blt/src/providers/providers_imports.dart'; /// The provider which exposes the state management /// for users in the global leaderboard list. diff --git a/lib/src/providers/leaderboards/monthlyleaderboard_provider.dart b/lib/src/providers/leaderboards/monthlyleaderboard_provider.dart index f9ada918da..5dcac3ff41 100644 --- a/lib/src/providers/leaderboards/monthlyleaderboard_provider.dart +++ b/lib/src/providers/leaderboards/monthlyleaderboard_provider.dart @@ -1,14 +1,11 @@ -import 'package:blt/src/models/leader_model.dart'; -import 'package:blt/src/util/api/leaderboard_api.dart'; -import 'package:blt/src/util/endpoints/leaderboard_endpoints.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import '../../models/leaderdata_model.dart'; +import 'package:blt/src/models/leaderdata_model.dart'; +import 'package:blt/src/providers/providers_imports.dart'; final monthlyLeaderBoardProvider = StateNotifierProvider< - MonthlyLeaderBoardNotifier, AsyncValue?>?>((ref){ - return MonthlyLeaderBoardNotifier(ref.read); - }); - + MonthlyLeaderBoardNotifier, AsyncValue?>?>((ref) { + return MonthlyLeaderBoardNotifier(ref.read); +}); + class MonthlyLeaderBoardNotifier extends StateNotifier?>?> { final Reader read; @@ -17,45 +14,44 @@ class MonthlyLeaderBoardNotifier MonthlyLeaderBoardNotifier(this.read, [AsyncValue>? leaderList]) : super(leaderList ?? const AsyncValue.loading()) { - _retrieveMonthlyLeaderList(DateTime.now().year,DateTime.now().month); + _retrieveMonthlyLeaderList(DateTime.now().year, DateTime.now().month); } - - Future _retrieveMonthlyLeaderList(int? year , int? month) async{ + Future _retrieveMonthlyLeaderList(int? year, int? month) async { try { - final LeaderData? monthlyLeaderData = - await LeaderboardApiClient.getMonthlyLeaderData( - LeaderboardEndpoints.monthly_leaderboard, - year, - month, - ); - nextUrl = monthlyLeaderData!.nextQuery; - state = AsyncValue.data(monthlyLeaderData.leaderList); - } catch(e) { + final LeaderData? monthlyLeaderData = + await LeaderboardApiClient.getMonthlyLeaderData( + LeaderboardEndpoints.monthly_leaderboard, + year, + month, + ); + nextUrl = monthlyLeaderData!.nextQuery; + state = AsyncValue.data(monthlyLeaderData.leaderList); + } catch (e) { AsyncValue.error(e); } } - Future getMoreMontlyLeaders () async{ + Future getMoreMontlyLeaders() async { _cacheState(); - try{ - final LeaderData leaderData = await LeaderboardApiClient.getMoreMonthlyLeaders(nextUrl); - nextUrl = leaderData.nextQuery; - state = state!.whenData((leaderList){ - leaderList!.addAll(leaderData.leaderList!); - return leaderList; - }); - } - catch(e){ + try { + final LeaderData leaderData = + await LeaderboardApiClient.getMoreMonthlyLeaders(nextUrl); + nextUrl = leaderData.nextQuery; + state = state!.whenData((leaderList) { + leaderList!.addAll(leaderData.leaderList!); + return leaderList; + }); + } catch (e) { _handleException(e); } } - Future refreshMonthlyLeaderList(int? year , int? month) async{ + Future refreshMonthlyLeaderList(int? year, int? month) async { state = const AsyncValue.loading(); - try{ + try { await _retrieveMonthlyLeaderList(year, month); - }catch(e){ + } catch (e) { AsyncValue.error(e); } } @@ -65,7 +61,7 @@ class MonthlyLeaderBoardNotifier previousState = state; } - void _resetState() { + void _resetState() { if (previousState != null) { state = previousState; previousState = null; @@ -76,4 +72,4 @@ class MonthlyLeaderBoardNotifier print(e); _resetState(); } - } \ No newline at end of file +} diff --git a/lib/src/providers/login_provider.dart b/lib/src/providers/login_provider.dart index 21469cfce6..fdd223cfa6 100644 --- a/lib/src/providers/login_provider.dart +++ b/lib/src/providers/login_provider.dart @@ -1,5 +1,4 @@ -import 'package:blt/src/util/enums/login_type.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:blt/src/providers/providers_imports.dart'; /// The provider which exposes the state management for /// the type of login (guest or user or logged out). diff --git a/lib/src/providers/providers_imports.dart b/lib/src/providers/providers_imports.dart new file mode 100644 index 0000000000..615342ee64 --- /dev/null +++ b/lib/src/providers/providers_imports.dart @@ -0,0 +1,20 @@ +export 'package:blt/src/util/enums/login_type.dart'; +export 'package:flutter_riverpod/flutter_riverpod.dart'; +export '../models/issue_model.dart'; +export '../models/issuedata_model.dart'; +export '../util/api/issues_api.dart'; +export '../util/endpoints/issue_endpoints.dart'; +export 'package:blt/src/pages/welcome.dart'; +export 'package:blt/src/util/api/user_api.dart'; +export 'package:flutter/material.dart'; +export 'package:flutter_secure_storage/flutter_secure_storage.dart'; +export './login_provider.dart'; +export '../models/user_model.dart'; +export '../routes/routing.dart'; +export '../global/variables.dart'; +export '../util/api/auth_api.dart'; +export '../util/enums/authstate_type.dart'; +export 'package:blt/src/models/company_model.dart'; +export 'package:blt/src/util/api/leaderboard_api.dart'; +export 'package:blt/src/util/endpoints/leaderboard_endpoints.dart'; +export 'package:blt/src/models/leader_model.dart'; diff --git a/lib/src/routes/routes_import.dart b/lib/src/routes/routes_import.dart new file mode 100644 index 0000000000..a7ec5ac9f1 --- /dev/null +++ b/lib/src/routes/routes_import.dart @@ -0,0 +1,21 @@ +export 'package:blt/src/models/issue_model.dart'; +export 'package:blt/src/pages/auth/forgot.dart'; +export 'package:blt/src/pages/auth/signup.dart'; +export 'package:blt/src/pages/drawer/change_password.dart'; +export 'package:blt/src/pages/error.dart'; +export 'package:blt/src/pages/home/home.dart'; +export 'package:blt/src/pages/drawer/legal.dart'; +export 'package:blt/src/pages/auth/login.dart'; +export 'package:blt/src/pages/home/profile.dart'; +export 'package:flutter/material.dart'; +export '../models/company_model.dart'; +export '../pages/company_details.dart'; +export '../pages/drawer/company_dashboard.dart'; +export '../pages/drawer/referral.dart'; +export '../pages/welcome.dart'; +export '../pages/drawer/about.dart'; +export '../pages/leaderboards/company_scoreboard.dart'; +export '../pages/leaderboards/global_leaderboard.dart'; +export '../pages/issues/issue_detail.dart'; +export '../pages/leaderboards/monthly_leaderboard.dart'; +export '../pages/drawer/social.dart'; diff --git a/lib/src/routes/routing.dart b/lib/src/routes/routing.dart index e874c88030..ec017a04b3 100644 --- a/lib/src/routes/routing.dart +++ b/lib/src/routes/routing.dart @@ -1,26 +1,4 @@ -import 'package:blt/src/models/issue_model.dart'; -import 'package:blt/src/pages/auth/forgot.dart'; -import 'package:blt/src/pages/auth/signup.dart'; -import 'package:blt/src/pages/drawer/change_password.dart'; -import 'package:blt/src/pages/error.dart'; -import 'package:blt/src/pages/home/home.dart'; -import 'package:blt/src/pages/drawer/legal.dart'; -import 'package:blt/src/pages/auth/login.dart'; -import 'package:blt/src/pages/home/profile.dart'; -import 'package:flutter/material.dart'; - -import '../models/company_model.dart'; -import '../pages/company_details.dart'; -import '../pages/drawer/company_dashboard.dart'; -import '../pages/drawer/referral.dart'; -import '../pages/welcome.dart'; -import '../pages/drawer/about.dart'; -import '../pages/leaderboards/company_scoreboard.dart'; -import '../pages/leaderboards/global_leaderboard.dart'; -import '../pages/issues/issue_detail.dart'; -import '../pages/leaderboards/monthly_leaderboard.dart'; -import '../pages/drawer/social.dart'; - +import 'package:blt/src/routes/routes_import.dart'; /// The managing class for App Navigation, also adds custom page transitions. class RouteManager { @@ -72,7 +50,7 @@ class RouteManager { case profilePage: return PageRouteBuilder( pageBuilder: (context, animation, secondaryAnimation) { - return UserProfile(); + return UserProfile(); }, transitionsBuilder: (context, animation, secondaryAnimation, child) { const begin = Offset(-1.0, 0); @@ -91,10 +69,9 @@ class RouteManager { ); case welcomePage: return PageRouteBuilder( - pageBuilder: (context, animation, secondaryAnimation) => - WelcomePage( - snackBarMessage: arguments as String?, - ), + pageBuilder: (context, animation, secondaryAnimation) => WelcomePage( + snackBarMessage: arguments as String?, + ), transitionsBuilder: (context, animation, secondaryAnimation, child) { const begin = Offset(1.0, 0); const end = Offset.zero; @@ -368,14 +345,14 @@ class RouteManager { case changePassword: return PageRouteBuilder( pageBuilder: (context, animation, secondaryAnimation) => - const ChangePasswordPage(), + const ChangePasswordPage(), transitionsBuilder: (context, animation, secondaryAnimation, child) { const begin = Offset(1.0, 0); const end = Offset.zero; const curve = Curves.ease; var tween = - Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); + Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); return SlideTransition( position: animation.drive(tween), @@ -385,7 +362,6 @@ class RouteManager { transitionDuration: const Duration(milliseconds: 750), ); - default: return PageRouteBuilder( pageBuilder: (context, animation, secondaryAnimation) => ErrorPage(), diff --git a/lib/src/util/api/auth_api.dart b/lib/src/util/api/auth_api.dart index dfa46040d5..837db53f54 100644 --- a/lib/src/util/api/auth_api.dart +++ b/lib/src/util/api/auth_api.dart @@ -1,12 +1,8 @@ import 'dart:convert'; - -import 'package:blt/src/models/user_model.dart'; -import 'package:blt/src/util/endpoints/auth_endpoints.dart'; +import 'package:blt/src/util/util_import.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; -import '../../global/variables.dart'; - /// Class for accessing the auth client. class AuthApiClient { AuthApiClient._(); @@ -127,10 +123,7 @@ class AuthApiClient { try { response = await http.post( Uri.parse(AuthEndPoints.emailpasswordLogin), - body: { - "username": currentUser!.username, - "password": password - }, + body: {"username": currentUser!.username, "password": password}, ); print(response.body); return response.statusCode == 200; @@ -139,15 +132,13 @@ class AuthApiClient { } /// Change the password of the logged in user. - static Future changePassword(String newPassword1, String newPassword2, BuildContext context) async { + static Future changePassword( + String newPassword1, String newPassword2, BuildContext context) async { http.Response? response; try { response = await http.post( Uri.parse(AuthEndPoints.change), - body: { - "new_password1": newPassword1, - "new_password2": newPassword2 - }, + body: {"new_password1": newPassword1, "new_password2": newPassword2}, headers: { "Authorization": "Token ${currentUser!.token!}", }, diff --git a/lib/src/util/api/company_api.dart b/lib/src/util/api/company_api.dart index 08e4ae6310..bad053b5d9 100644 --- a/lib/src/util/api/company_api.dart +++ b/lib/src/util/api/company_api.dart @@ -1,10 +1,7 @@ import 'dart:convert'; - -import 'package:blt/src/util/endpoints/company_endpoints.dart'; +import 'package:blt/src/util/util_import.dart'; import 'package:http/http.dart' as http; -import '../../models/company_model.dart'; - /// CLass for accessing the company client. class CompanyApiClient { CompanyApiClient._(); diff --git a/lib/src/util/api/general_api.dart b/lib/src/util/api/general_api.dart index e3ffd8deb1..1c2506aabe 100644 --- a/lib/src/util/api/general_api.dart +++ b/lib/src/util/api/general_api.dart @@ -1,6 +1,5 @@ import 'dart:convert'; - -import 'package:blt/src/util/endpoints/general_endpoints.dart'; +import 'package:blt/src/util/util_import.dart'; import 'package:http/http.dart' as http; /// Class for accessing the general client. diff --git a/lib/src/util/api/issues_api.dart b/lib/src/util/api/issues_api.dart index a277dabde6..370d1ae7b9 100644 --- a/lib/src/util/api/issues_api.dart +++ b/lib/src/util/api/issues_api.dart @@ -1,12 +1,7 @@ import 'dart:convert'; -import 'package:blt/src/global/variables.dart'; -import 'package:blt/src/models/user_model.dart'; -import 'package:blt/src/routes/routing.dart'; -import 'package:blt/src/util/endpoints/issue_endpoints.dart'; +import 'package:blt/src/util/util_import.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; -import '../../models/issuedata_model.dart'; -import '../../models/issue_model.dart'; /// Class for accessing the issue client. class IssueApiClient { diff --git a/lib/src/util/api/leaderboard_api.dart b/lib/src/util/api/leaderboard_api.dart index d219f05289..45bb3043ab 100644 --- a/lib/src/util/api/leaderboard_api.dart +++ b/lib/src/util/api/leaderboard_api.dart @@ -1,8 +1,6 @@ -import 'package:blt/src/models/company_model.dart'; -import 'package:blt/src/models/leaderdata_model.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; -import '../../models/leader_model.dart'; +import 'package:blt/src/util/util_import.dart'; class LeaderboardApiClient { LeaderboardApiClient._(); @@ -21,48 +19,51 @@ class LeaderboardApiClient { }); } - static Future getMonthlyLeaderData(String paginatedUrl,int? year , int? month) async{ + static Future getMonthlyLeaderData( + String paginatedUrl, int? year, int? month) async { final queryParams = { - "filter" : '1', - "year" : year.toString() , - "month" : month.toString() , + "filter": '1', + "year": year.toString(), + "month": month.toString(), }; print(Uri.parse(paginatedUrl).replace(queryParameters: queryParams)); return http - .get( + .get( Uri.parse(paginatedUrl).replace(queryParameters: queryParams), ) - .then((http.Response response){ - List leaderList = []; - var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)); - decodedResponse["results"].forEach((element) { - leaderList.add(Leaders.fromJson(element)); - }); - LeaderData leaderData = LeaderData( - count: decodedResponse["count"], - nextQuery: decodedResponse["next"], - previousQuery: decodedResponse["previous"], - leaderList: leaderList, - ); + .then((http.Response response) { + List leaderList = []; + var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)); + decodedResponse["results"].forEach((element) { + leaderList.add(Leaders.fromJson(element)); + }); + LeaderData leaderData = LeaderData( + count: decodedResponse["count"], + nextQuery: decodedResponse["next"], + previousQuery: decodedResponse["previous"], + leaderList: leaderList, + ); return leaderData; }); } - static Future getMoreMonthlyLeaders (String? nextUrl) async{ - return http.get( + static Future getMoreMonthlyLeaders(String? nextUrl) async { + return http + .get( Uri.parse(nextUrl!), - ).then((http.Response response){ - List leaderList = []; - var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)); - decodedResponse["results"].forEach((element) { + ) + .then((http.Response response) { + List leaderList = []; + var decodedResponse = jsonDecode(utf8.decode(response.bodyBytes)); + decodedResponse["results"].forEach((element) { leaderList.add(Leaders.fromJson(element)); - }); - LeaderData leaderData = LeaderData( - count: decodedResponse["count"], - nextQuery: decodedResponse["next"], - previousQuery: decodedResponse["previous"], - leaderList: leaderList, - ); + }); + LeaderData leaderData = LeaderData( + count: decodedResponse["count"], + nextQuery: decodedResponse["next"], + previousQuery: decodedResponse["previous"], + leaderList: leaderList, + ); return leaderData; }); } diff --git a/lib/src/util/api/user_api.dart b/lib/src/util/api/user_api.dart index 1f152497cc..06760456ee 100644 --- a/lib/src/util/api/user_api.dart +++ b/lib/src/util/api/user_api.dart @@ -1,9 +1,6 @@ import 'dart:convert'; - -import 'package:blt/src/util/endpoints/user_endpoints.dart'; +import 'package:blt/src/util/util_import.dart'; import 'package:http/http.dart' as http; -import 'package:blt/src/models/user_model.dart'; -import 'package:image_picker/image_picker.dart'; class UserApiClient { UserApiClient._(); @@ -58,7 +55,8 @@ class UserApiClient { final uri = Uri.parse(updateUrl); var request = new http.MultipartRequest('PUT', uri); - final httpImage = await http.MultipartFile.fromPath('user_avatar', image.path, + final httpImage = await http.MultipartFile.fromPath( + 'user_avatar', image.path, filename: image.name); request.files.add(httpImage); request.headers.addAll( diff --git a/lib/src/util/endpoints/auth_endpoints.dart b/lib/src/util/endpoints/auth_endpoints.dart index 73d9e5d6e5..3f17900255 100644 --- a/lib/src/util/endpoints/auth_endpoints.dart +++ b/lib/src/util/endpoints/auth_endpoints.dart @@ -6,7 +6,8 @@ class AuthEndPoints { static const String authBaseUrl = GeneralEndPoints.baseUrl + "auth/"; - static const String emailpasswordLogin = GeneralEndPoints.baseUrl + "authenticate/"; + static const String emailpasswordLogin = + GeneralEndPoints.baseUrl + "authenticate/"; static const String logout = authBaseUrl + "logout/"; diff --git a/lib/src/util/endpoints/leaderboard_endpoints.dart b/lib/src/util/endpoints/leaderboard_endpoints.dart index f079b69cc9..d4bdb88c9c 100644 --- a/lib/src/util/endpoints/leaderboard_endpoints.dart +++ b/lib/src/util/endpoints/leaderboard_endpoints.dart @@ -3,9 +3,12 @@ import 'general_endpoints.dart'; class LeaderboardEndpoints { LeaderboardEndpoints._(); - static const String globalLeaderboard = GeneralEndPoints.apiBaseUrl + "userscore/"; + static const String globalLeaderboard = + GeneralEndPoints.apiBaseUrl + "userscore/"; - static const String monthly_leaderboard = GeneralEndPoints.apiBaseUrl + "leaderboard/"; + static const String monthly_leaderboard = + GeneralEndPoints.apiBaseUrl + "leaderboard/"; - static const String companyScoreboard = GeneralEndPoints.apiBaseUrl + "scoreboard/"; + static const String companyScoreboard = + GeneralEndPoints.apiBaseUrl + "scoreboard/"; } diff --git a/lib/src/util/endpoints/user_endpoints.dart b/lib/src/util/endpoints/user_endpoints.dart index 2ba1fdddf2..367fe7fd18 100644 --- a/lib/src/util/endpoints/user_endpoints.dart +++ b/lib/src/util/endpoints/user_endpoints.dart @@ -6,5 +6,6 @@ class UserEndPoints { static const String userInfo = GeneralEndPoints.apiBaseUrl + "profile/"; - static const String userData = GeneralEndPoints.apiBaseUrl + "profile/auth/user/"; + static const String userData = + GeneralEndPoints.apiBaseUrl + "profile/auth/user/"; } diff --git a/lib/src/util/services/shared_preferences.dart b/lib/src/util/services/shared_preferences.dart index 1852bcb86c..5a19d3e58d 100644 --- a/lib/src/util/services/shared_preferences.dart +++ b/lib/src/util/services/shared_preferences.dart @@ -1,7 +1,8 @@ -import '../../models/user_model.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'dart:async'; +import 'package:blt/src/util/util_import.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + class UserPreferences { Future saveUser(User user) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); diff --git a/lib/src/util/util_import.dart b/lib/src/util/util_import.dart new file mode 100644 index 0000000000..428eab13bb --- /dev/null +++ b/lib/src/util/util_import.dart @@ -0,0 +1,14 @@ +export 'package:blt/src/models/user_model.dart'; +export 'package:blt/src/util/endpoints/auth_endpoints.dart'; +export 'package:blt/src/util/endpoints/company_endpoints.dart'; +export 'package:blt/src/util/endpoints/general_endpoints.dart'; +export 'package:blt/src/global/variables.dart'; +export 'package:blt/src/routes/routing.dart'; +export 'package:blt/src/util/endpoints/issue_endpoints.dart'; +export 'package:blt/src/models/company_model.dart'; +export 'package:blt/src/models/leaderdata_model.dart'; +export 'package:blt/src/util/endpoints/user_endpoints.dart'; +export 'package:image_picker/image_picker.dart'; +export 'package:blt/src/models/leader_model.dart'; +export 'package:blt/src/models/issuedata_model.dart'; +export 'package:blt/src/models/issue_model.dart'; From d44f09c85eaca337ddc97fccc465b8b06b5d5f8d Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Sun, 25 Feb 2024 23:33:18 +0530 Subject: [PATCH 10/13] app localisation + list view error solved --- android/app/build.gradle | 2 +- lib/src/pages/home/home_imports.dart | 1 + lib/src/pages/home/issues.dart | 7 ++++++- lib/src/pages/issues/issues_import.dart | 1 + lib/src/pages/leaderboards/leaderboards_imports.dart | 1 + lib/src/pages/pages_import.dart | 2 ++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 46651b3b14..cf30b3b98a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -27,7 +27,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 33 + compileSdkVersion 34 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/lib/src/pages/home/home_imports.dart b/lib/src/pages/home/home_imports.dart index 50f8c80512..804ef452e7 100644 --- a/lib/src/pages/home/home_imports.dart +++ b/lib/src/pages/home/home_imports.dart @@ -36,3 +36,4 @@ export 'package:flutter_svg/flutter_svg.dart'; export 'package:url_launcher/url_launcher.dart'; export 'package:flutter_markdown/flutter_markdown.dart'; export 'package:pasteboard/pasteboard.dart'; +export 'package:flutter_gen/gen_l10n/app_localizations.dart'; diff --git a/lib/src/pages/home/issues.dart b/lib/src/pages/home/issues.dart index 145e0f86d7..4f86e69d3c 100644 --- a/lib/src/pages/home/issues.dart +++ b/lib/src/pages/home/issues.dart @@ -108,12 +108,17 @@ class IssuesPageState extends ConsumerState ), ); } else { + print(issueList.length); return ListView.builder( controller: _scrollController, itemCount: issueList.length, itemBuilder: (context, index) { + final currentIssue = issueList[index]; + if (currentIssue.screenshotsLink!.isEmpty) { + return Container(); + } return IssueCard( - issue: issueList[index], + issue: currentIssue, ); }, ); diff --git a/lib/src/pages/issues/issues_import.dart b/lib/src/pages/issues/issues_import.dart index dcb060cfc1..f37ba412f6 100644 --- a/lib/src/pages/issues/issues_import.dart +++ b/lib/src/pages/issues/issues_import.dart @@ -4,3 +4,4 @@ export '../../models/issue_model.dart'; export '../../components/issuechip.dart'; export '../../components/issueflag.dart'; export '../../components/issuelike.dart'; +export 'package:flutter_gen/gen_l10n/app_localizations.dart'; diff --git a/lib/src/pages/leaderboards/leaderboards_imports.dart b/lib/src/pages/leaderboards/leaderboards_imports.dart index 865ecb5e6c..16acd7c328 100644 --- a/lib/src/pages/leaderboards/leaderboards_imports.dart +++ b/lib/src/pages/leaderboards/leaderboards_imports.dart @@ -8,3 +8,4 @@ export 'package:blt/src/providers/leaderboards/monthlyleaderboard_provider.dart' export 'package:flutter_riverpod/flutter_riverpod.dart'; export '../../models/leader_model.dart'; export '../../constants/monthname_constants.dart'; +export 'package:flutter_gen/gen_l10n/app_localizations.dart'; diff --git a/lib/src/pages/pages_import.dart b/lib/src/pages/pages_import.dart index 4dc3135f3a..7f8916ed8c 100644 --- a/lib/src/pages/pages_import.dart +++ b/lib/src/pages/pages_import.dart @@ -32,3 +32,5 @@ export 'package:flutter/gestures.dart'; export 'package:pasteboard/pasteboard.dart'; export 'package:blt/src/global/variables.dart'; export 'package:blt/src/pages/welcome.dart'; +export 'package:flutter_gen/gen_l10n/app_localizations.dart'; +export 'package:blt/src/providers/language_provider.dart'; From 88328dba67e2c739e49db720d7c0513d1ff73a0a Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Sun, 25 Feb 2024 23:36:05 +0530 Subject: [PATCH 11/13] removed debug statement --- lib/src/pages/home/issues.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/pages/home/issues.dart b/lib/src/pages/home/issues.dart index 4f86e69d3c..9569292532 100644 --- a/lib/src/pages/home/issues.dart +++ b/lib/src/pages/home/issues.dart @@ -108,7 +108,6 @@ class IssuesPageState extends ConsumerState ), ); } else { - print(issueList.length); return ListView.builder( controller: _scrollController, itemCount: issueList.length, From 27703c03e246d4274dac5678d23c843ae7d0599e Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Mon, 26 Feb 2024 17:07:58 +0530 Subject: [PATCH 12/13] dark mode provider added --- lib/src/pages/home/home_imports.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/pages/home/home_imports.dart b/lib/src/pages/home/home_imports.dart index 804ef452e7..d51214b79b 100644 --- a/lib/src/pages/home/home_imports.dart +++ b/lib/src/pages/home/home_imports.dart @@ -6,6 +6,7 @@ export 'package:blt/src/pages/home/leaderboard.dart'; export 'package:blt/src/pages/home/report_bug.dart'; export 'package:blt/src/pages/home/start_hunt.dart'; export 'package:blt/src/providers/authstate_provider.dart'; +export 'package:blt/src/providers//dark_mode_provider.dart'; export 'package:blt/src/providers/login_provider.dart'; export 'package:blt/src/routes/routing.dart'; export 'package:blt/src/util/enums/login_type.dart'; From 18f18bfb1de0ebd7654c5628d83af4ef717ec0a9 Mon Sep 17 00:00:00 2001 From: Uttkarsh-raj Date: Mon, 26 Feb 2024 17:37:46 +0530 Subject: [PATCH 13/13] unused import --- lib/src/pages/home/start_hunt.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/src/pages/home/start_hunt.dart b/lib/src/pages/home/start_hunt.dart index f0d63baef4..7f0dbbb30d 100644 --- a/lib/src/pages/home/start_hunt.dart +++ b/lib/src/pages/home/start_hunt.dart @@ -2,7 +2,6 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:blt/src/pages/home/home_imports.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:flutter_gen/gen_l10n/app_localizations.dart'; /// Start Bug Hunt Page /// companies and individuals