diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index 0a73738..3f554fd 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:flutter/foundation.dart'; import 'package:http/http.dart'; import 'package:http/io_client.dart'; import 'package:tangheem/exceptions/api_exception.dart'; @@ -60,14 +61,15 @@ class ApiClient { if (headers != null && headers.isNotEmpty) { _headers.addAll(headers); } - print("Url:$url"); - print("body:$jsonObject"); + if (!kReleaseMode) { + print("Url:$url"); + print("body:$jsonObject"); + } var response = await postJsonForResponse(url, jsonObject, token: token, queryParameters: queryParameters, headers: _headers, retryTimes: retryTimes); try { var jsonData = jsonDecode(response.body); return factoryConstructor(jsonData); } catch (ex, tr) { - print('${ex.runtimeType}\n$ex\n$tr'); throw APIException(APIException.BAD_RESPONSE_FORMAT, arguments: ex); } } diff --git a/lib/models/bookmark_model.dart b/lib/models/bookmark_model.dart index c68d7da..7de7a3b 100644 --- a/lib/models/bookmark_model.dart +++ b/lib/models/bookmark_model.dart @@ -51,6 +51,5 @@ class BookMarkModel { List encodedList = list.map((e) => jsonEncode(e.toJson())).toList(); var abc = await prefs.setStringList(GlobalConsts.bookmark, encodedList); - print("saveToPrefs:$abc"); } } diff --git a/lib/ui/bottom_sheets/country_selection_bottom_sheet.dart b/lib/ui/bottom_sheets/country_selection_bottom_sheet.dart index 7f5d0d2..fb00af2 100644 --- a/lib/ui/bottom_sheets/country_selection_bottom_sheet.dart +++ b/lib/ui/bottom_sheets/country_selection_bottom_sheet.dart @@ -38,7 +38,6 @@ class _CountrySelectionBottomSheetState extends State { setState(() {}); Utils.hideLoading(context); } catch (ex, tr) { - print(ex); Utils.hideLoading(context); Utils.handleException(ex, null); } diff --git a/lib/ui/screens/quran_screen.dart b/lib/ui/screens/quran_screen.dart index 34de748..9610679 100644 --- a/lib/ui/screens/quran_screen.dart +++ b/lib/ui/screens/quran_screen.dart @@ -13,7 +13,6 @@ import 'package:tangheem/models/aya_model.dart'; import 'package:tangheem/models/aya_tangheem_type_mapped.dart'; import 'package:tangheem/models/bookmark_model.dart'; import 'package:tangheem/models/surah_model.dart'; -import 'package:tangheem/widgets/auto_scroll_view/scroll_id.dart'; import 'package:tangheem/widgets/common_dropdown_button.dart'; import 'tangheem_detail_screen.dart'; @@ -53,7 +52,6 @@ class _QuranScreenState extends State { @override void initState() { super.initState(); - scrollToId = ScrollToId(scrollController: scrollController); getBookMark(); getPrefs(); getSurah(); @@ -133,7 +131,6 @@ class _QuranScreenState extends State { Utils.hideLoading(context); } getTangheemBySurahId(); - scrollToId.animateTo("$_currentPage", duration: Duration(milliseconds: 300), curve: Curves.ease); } void getQuranByPageNo() async { @@ -146,7 +143,6 @@ class _QuranScreenState extends State { Utils.handleException(ex, null); Utils.hideLoading(context); } - scrollToId.animateTo("$_currentPage", duration: Duration(milliseconds: 300), curve: Curves.ease); } int getNextMultiple(int num) { @@ -161,9 +157,6 @@ class _QuranScreenState extends State { super.dispose(); } - final ScrollController scrollController = ScrollController(); - ScrollToId scrollToId; - String getBismillahWithSurahName(int _surahID, String _surahName, bool isShowBismillah, bool isFirstIsAya) { String _bismillah = "\n بِسۡمِ ٱللَّهِ ٱلرَّحۡمَٰنِ ٱلرَّحِيم"; if (_surahID == 9) { @@ -242,7 +235,6 @@ class _QuranScreenState extends State { if (_selectedFromAya != index) { _selectedFromAya = index; var abc = filteredAyahList.indexOf(_selectedFromAya); - print("index:$abc"); _toAyaList = filteredAyahList.getRange(_selectedFromAya + 1, filteredAyahList.length)?.toList() ?? []; setState(() {}); } diff --git a/lib/ui/screens/tangheem_detail_screen.dart b/lib/ui/screens/tangheem_detail_screen.dart index 10cae48..d101205 100644 --- a/lib/ui/screens/tangheem_detail_screen.dart +++ b/lib/ui/screens/tangheem_detail_screen.dart @@ -96,7 +96,6 @@ class _TangheemDetailScreenState extends State { Utils.hideLoading(context); Navigator.pop(context); } catch (ex, tr) { - print(ex); Utils.handleException(ex, null); Utils.hideLoading(context); } diff --git a/lib/widgets/auto_scroll_view/aya_scroll_view.dart b/lib/widgets/auto_scroll_view/aya_scroll_view.dart deleted file mode 100644 index 687fe67..0000000 --- a/lib/widgets/auto_scroll_view/aya_scroll_view.dart +++ /dev/null @@ -1,78 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:tangheem/widgets/auto_scroll_view/scroll_id.dart'; - -class AyaScrollViewer extends StatefulWidget { - final ScrollToId scrollToId; - final List children; - final Axis scrollDirection; - - AyaScrollViewer({@required this.children, @required this.scrollToId, this.scrollDirection = Axis.vertical}); - - @override - _InteractiveScrollViewerState createState() => _InteractiveScrollViewerState(); -} - -class _InteractiveScrollViewerState extends State { - List _idList = []; - - @override - void initState() { - super.initState(); - setData(); - } - - void setData() { - widget.scrollToId.scrollDirection = widget.scrollDirection; - _idList = []; - widget.scrollToId.scrollContentsList = []; - for (ScrollContent scrollContents in widget.children) { - if (_idList.contains(scrollContents.id)) { - throw Exception('Do not use the same id'); - } else { - _idList.add(scrollContents.id); - } - widget.scrollToId.scrollContentsList.add(ScrollContentWithKey.fromWithout(scrollContents)); - } - } - - @override - void didUpdateWidget(covariant AyaScrollViewer oldWidget) { - if (widget.children != oldWidget.children) { - setData(); - } - super.didUpdateWidget(oldWidget); - } - - @override - Widget build(BuildContext context) { - return SingleChildScrollView( - scrollDirection: widget.scrollDirection, - controller: widget.scrollToId.scrollController, - physics: BouncingScrollPhysics(), - child: buildContent(), - ); - } - - Widget buildContent() { - if (widget.scrollDirection == Axis.vertical) { - return Column( - children: widget.scrollToId.scrollContentsList.map((scrollContents) { - return buildRepaintBoundary(scrollContents); - }).toList(), - ); - } else { - return Row( - children: widget.scrollToId.scrollContentsList.map((scrollContents) { - return buildRepaintBoundary(scrollContents); - }).toList(), - ); - } - } - - RepaintBoundary buildRepaintBoundary(ScrollContentWithKey scrollContents) { - return RepaintBoundary( - key: scrollContents.key, - child: scrollContents.child, - ); - } -} diff --git a/lib/widgets/auto_scroll_view/scroll_id.dart b/lib/widgets/auto_scroll_view/scroll_id.dart deleted file mode 100644 index b84fd48..0000000 --- a/lib/widgets/auto_scroll_view/scroll_id.dart +++ /dev/null @@ -1,136 +0,0 @@ -import 'package:flutter/material.dart'; - -class ScrollToId { - final ScrollController scrollController; - List scrollContentsList = []; - Axis scrollDirection; - - ScrollToId({this.scrollController}); - - String idPosition() { - double sumSize = 0; - for (ScrollContentWithKey scrollContents in scrollContentsList) { - if (scrollDirection == Axis.vertical) { - sumSize += scrollContents.key.currentContext.size.height; - } else { - sumSize += scrollContents.key.currentContext.size.width; - } - - if (scrollController.offset < sumSize) { - return scrollContents.id; - } - } - return null; - } - - Future animateTo(String id, {@required Duration duration, @required Curve curve}) async { - Function _function = (double offset) { - scrollController.animateTo(offset, duration: duration, curve: curve); - }; - _scroll(id: id, scrollFunction: _function); - } - - Future jumpTo(String id) async { - Function _function = (double offset) { - scrollController.jumpTo(offset); - }; - _scroll(id: id, scrollFunction: _function); - } - - Future animateToNext({@required Duration duration, @required Curve curve}) async { - Function _function = (double offset) { - scrollController.animateTo(offset, duration: duration, curve: curve); - }; - _scroll(id: _getNextId(number: 1), scrollFunction: _function); - } - - Future jumpToNext() async { - Function _function = (double offset) { - scrollController.jumpTo(offset); - }; - _scroll(id: _getNextId(number: 1), scrollFunction: _function); - } - - Future animateToBefore({@required Duration duration, @required Curve curve}) async { - Function _function = (double offset) { - scrollController.animateTo(offset, duration: duration, curve: curve); - }; - _scroll(id: _getNextId(number: -1), scrollFunction: _function); - } - - Future jumpToBefore() async { - Function _function = (double offset) { - scrollController.jumpTo(offset); - }; - _scroll(id: _getNextId(number: -1), scrollFunction: _function); - } - - String _getNextId({int number}) { - double sumSize = 0; - for (int i = 0; i < scrollContentsList.length; i++) { - if (scrollDirection == Axis.vertical) { - sumSize += scrollContentsList[i].key.currentContext.size.height; - } else { - sumSize += scrollContentsList[i].key.currentContext.size.width; - } - - if (scrollController.offset < sumSize) { - if (number == 1 && i == scrollContentsList.length - 1) return null; - if (number == -1 && i == 0) return null; - - return scrollContentsList[i + number].id; - } - } - return null; - } - - void _scroll({String id, Function scrollFunction}) { - double sumSize = 0; - - for (ScrollContentWithKey scrollContents in scrollContentsList) { - if (scrollContents.id == id) { - try { - if (sumSize < scrollController.position.maxScrollExtent) { - scrollFunction(sumSize); - break; - } else { - scrollFunction(scrollController.position.maxScrollExtent); - break; - } - } catch (e) { - print('$e'); - break; - } - } else { - try { - if (scrollDirection == Axis.vertical) { - sumSize += scrollContents.key.currentContext.size.height; - } else { - sumSize += scrollContents.key.currentContext.size.width; - } - } catch (e) { - print('$e'); - } - } - } - } -} - -class ScrollContent { - final String id; - final Widget child; - - ScrollContent({@required this.id, @required this.child}); -} - -class ScrollContentWithKey { - final Widget child; - final String id; - final GlobalKey key; - - ScrollContentWithKey({this.child, this.key, this.id}); - - factory ScrollContentWithKey.fromWithout(ScrollContent scrollContent) { - return ScrollContentWithKey(child: scrollContent.child, id: scrollContent.id, key: GlobalKey()); - } -}