code improvements.

development
Sikander Saleem 5 years ago
parent c7cb0c8357
commit c70252c613

@ -75,7 +75,6 @@ class _CountrySelectionBottomSheetState extends State<CountrySelectionBottomShee
bottomLeft: Radius.circular(12), bottomLeft: Radius.circular(12),
), ),
), ),
// color: Const.primaryBlue,
child: CommonTextFieldWidget(hint: "البحث في البلد", controller: _searchCountryController), child: CommonTextFieldWidget(hint: "البحث في البلد", controller: _searchCountryController),
), ),
Expanded( Expanded(

@ -243,10 +243,8 @@ class _CommonAppbarState extends State<CommonAppbar> {
}), }),
), ),
Container( Container(
// width: 35,
height: 40, height: 40,
margin: EdgeInsets.only(right: 17, left: 10), margin: EdgeInsets.only(right: 17, left: 10),
// color: Const.primaryBlack,
child: VerticalDivider(color: ColorConsts.primaryBlack, thickness: .7, width: 1), child: VerticalDivider(color: ColorConsts.primaryBlack, thickness: .7, width: 1),
), ),
], ],
@ -281,7 +279,6 @@ class _CommonAppbarState extends State<CommonAppbar> {
), ),
SizedBox(width: 8), SizedBox(width: 8),
Image.network(_copyRight.exposeFilePath, width: 30, height: 30) Image.network(_copyRight.exposeFilePath, width: 30, height: 30)
//SvgPicture.asset("assets/logos/cloud_logo.svg", width: 30, height: 30)
], ],
), ),
) )

@ -58,11 +58,9 @@ class _OTPDialogState extends State<OTPDialog> {
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
Container( Container(
// width: double.infinity,
margin: EdgeInsets.only(top: 8, bottom: 8), margin: EdgeInsets.only(top: 8, bottom: 8),
padding: EdgeInsets.all(6), padding: EdgeInsets.all(6),
decoration: BoxDecoration( decoration: BoxDecoration(
// color: Colors.white,
border: Border.all(width: 1, color: Colors.white), border: Border.all(width: 1, color: Colors.white),
), ),
child: OTPWidget( child: OTPWidget(

@ -37,15 +37,9 @@ class _BookmarkScreenState extends State<BookmarkScreen> {
} }
void handleSlideAnimationChanged(Animation<double> slideAnimation) { void handleSlideAnimationChanged(Animation<double> slideAnimation) {
// setState(() {
// _rotationAnimation = slideAnimation;
// });
} }
void handleSlideIsOpenChanged(bool isOpen) { void handleSlideIsOpenChanged(bool isOpen) {
// setState(() {
// _fabColor = isOpen! ? Colors.green : Colors.blue;
// });
} }
void getBookMark() async { void getBookMark() async {

@ -4,7 +4,6 @@ import 'package:tangheem/api/user_api_client.dart';
import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/colors.dart';
import 'package:tangheem/classes/utils.dart'; import 'package:tangheem/classes/utils.dart';
import 'package:tangheem/extensions/string_extensions.dart'; import 'package:tangheem/extensions/string_extensions.dart';
import 'package:tangheem/models/general_response_model.dart';
import 'package:tangheem/ui/dialogs/change_password_dialog.dart'; import 'package:tangheem/ui/dialogs/change_password_dialog.dart';
import 'package:tangheem/ui/dialogs/otp_dialog.dart'; import 'package:tangheem/ui/dialogs/otp_dialog.dart';
import 'package:tangheem/widgets/common_textfield_widget.dart'; import 'package:tangheem/widgets/common_textfield_widget.dart';
@ -22,7 +21,6 @@ class ForgotPasswordScreen extends StatefulWidget {
class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> { class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
TextEditingController _emailController = TextEditingController(); TextEditingController _emailController = TextEditingController();
GeneralResponseModel _generalResponse;
@override @override
void initState() { void initState() {
@ -37,7 +35,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
void forgotPassword(String email) async { void forgotPassword(String email) async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
_generalResponse = await UserApiClient().forgotPassword(email); await UserApiClient().forgotPassword(email);
Utils.showToast("تم إرسال OTP"); Utils.showToast("تم إرسال OTP");
} catch (ex, tr) { } catch (ex, tr) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
@ -52,7 +50,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
void verifyOTP(String email, int otp) async { void verifyOTP(String email, int otp) async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
_generalResponse = await UserApiClient().verifyOTP(email, otp); await UserApiClient().verifyOTP(email, otp);
} catch (ex, tr) { } catch (ex, tr) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);
@ -67,7 +65,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
void updatePassword(String email, int otp, String password) async { void updatePassword(String email, int otp, String password) async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
_generalResponse = await UserApiClient().updatePassword(email, otp, password); await UserApiClient().updatePassword(email, otp, password);
} catch (ex, tr) { } catch (ex, tr) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
Utils.hideLoading(context); Utils.hideLoading(context);

@ -27,9 +27,9 @@ class _HomeScreenState extends State<HomeScreen> {
TextEditingController _searchController = TextEditingController(); TextEditingController _searchController = TextEditingController();
FocusNode _searchFocusNode = FocusNode(); FocusNode _searchFocusNode = FocusNode();
List<String> _surahList = []; ValueNotifier<List<String>> _tangheemListNotifier = ValueNotifier([]);
List<String> _tangheemList = [];
List<String> _surahList = [];
int _selectedSurah = -1; int _selectedSurah = -1;
int _selectedTangheemType = -1; int _selectedTangheemType = -1;
@ -51,6 +51,7 @@ class _HomeScreenState extends State<HomeScreen> {
_surahList = _surahModel.data.map((element) => element.nameAR).toList(); _surahList = _surahModel.data.map((element) => element.nameAR).toList();
await getTangheemTypes(); await getTangheemTypes();
TangheemUserApiClient().addStatistics(1); TangheemUserApiClient().addStatistics(1);
setState(() {});
Utils.hideLoading(context); Utils.hideLoading(context);
} catch (ex, tr) { } catch (ex, tr) {
print(ex); print(ex);
@ -62,8 +63,7 @@ class _HomeScreenState extends State<HomeScreen> {
Future<void> getTangheemTypes() async { Future<void> getTangheemTypes() async {
try { try {
_tangheemType = await TangheemUserApiClient().getTangheemType(); _tangheemType = await TangheemUserApiClient().getTangheemType();
_tangheemList = _tangheemType?.data?.where((element) => element.isActive)?.toList()?.map((element) => element.tangheemTypeName)?.toList() ?? []; _tangheemListNotifier.value = _tangheemType?.data?.where((element) => element.isActive)?.toList()?.map((element) => element.tangheemTypeName)?.toList() ?? [];
setState(() {});
} catch (ex, tr) {} } catch (ex, tr) {}
} }
@ -101,13 +101,18 @@ class _HomeScreenState extends State<HomeScreen> {
Row( Row(
children: [ children: [
Expanded( Expanded(
child: CommonDropDownButton(_selectedTangheemType, hintText: "اختر الأسلوب اللغوي", list: _tangheemList, onSelect: (index) { child: ValueListenableBuilder(
if (_selectedTangheemType != index) { valueListenable: _tangheemListNotifier,
setState(() { builder: (context, value, child) {
_selectedTangheemType = index; return CommonDropDownButton(_selectedTangheemType, hintText: "اختر الأسلوب اللغوي", list: value, onSelect: (index) {
if (_selectedTangheemType != index) {
setState(() {
_selectedTangheemType = index;
});
}
}); });
} },
}), ),
), ),
SizedBox(width: 8), SizedBox(width: 8),
Expanded( Expanded(
@ -136,7 +141,7 @@ class _HomeScreenState extends State<HomeScreen> {
} }
_searchFocusNode.unfocus(); _searchFocusNode.unfocus();
_searchFocusNode.canRequestFocus = false; _searchFocusNode.canRequestFocus = false;
var data = {"tangheemTypeName": _tangheemList[_selectedTangheemType], "surahData": _surahModel.data[_selectedSurah]}; var data = {"tangheemTypeName": _tangheemListNotifier.value[_selectedTangheemType], "surahData": _surahModel.data[_selectedSurah]};
await Navigator.pushNamed(context, TangheemScreen.routeName, arguments: data); await Navigator.pushNamed(context, TangheemScreen.routeName, arguments: data);
_searchFocusNode.canRequestFocus = true; _searchFocusNode.canRequestFocus = true;
getTangheemTypes(); getTangheemTypes();

@ -31,7 +31,6 @@ class QuranScreen extends StatefulWidget {
} }
class _QuranScreenState extends State<QuranScreen> { class _QuranScreenState extends State<QuranScreen> {
GlobalKey _globalKey = GlobalKey();
int _selectedSurah = -1; int _selectedSurah = -1;
int _selectedFromAya = -1; int _selectedFromAya = -1;
int _selectedToAya = -1; int _selectedToAya = -1;
@ -81,9 +80,7 @@ class _QuranScreenState extends State<QuranScreen> {
} }
_surahList = _surahModel.data.map((element) => element.nameAR).toList(); _surahList = _surahModel.data.map((element) => element.nameAR).toList();
_currentPage = widget.bookmark?.page ?? 1; _currentPage = widget.bookmark?.page ?? 1;
Utils.hideLoading(context); Utils.hideLoading(context);
//filterData();
} catch (ex, tr) { } catch (ex, tr) {
Utils.hideLoading(context); Utils.hideLoading(context);
Utils.handleException(ex, null); Utils.handleException(ex, null);
@ -113,33 +110,23 @@ class _QuranScreenState extends State<QuranScreen> {
filteredAyahList = List.generate(getNextMultiple(numberOfAyah), (index) => index + 1).toList().where((element) => element == 1 || (element % 5) == 0).toList() ?? []; filteredAyahList = List.generate(getNextMultiple(numberOfAyah), (index) => index + 1).toList().where((element) => element == 1 || (element % 5) == 0).toList() ?? [];
_fromAyaList = filteredAyahList.getRange(0, filteredAyahList.length - 1)?.toList() ?? []; _fromAyaList = filteredAyahList.getRange(0, filteredAyahList.length - 1)?.toList() ?? [];
// _toAyaList = filteredAyahList.getRange(1, filteredAyahList.length)?.toList() ?? [];
// _currentPage = 0;
// _selectedFromAya = 0;
// _selectedToAya = 0;
setState(() {}); setState(() {});
// getTangheemBySurahId();
} }
void getTangheemBySurahId() async { void getTangheemBySurahId() async {
//Utils.showLoading(context);
try { try {
_ayatTangheemTypeMapped = await TangheemUserApiClient().getTangheemBySurah(_selectedSurah + 1); _ayatTangheemTypeMapped = await TangheemUserApiClient().getTangheemBySurah(_selectedSurah + 1);
_tangheemWords = _ayatTangheemTypeMapped?.data?.map((e) => e.highlightText)?.toList() ?? []; _tangheemWords = _ayatTangheemTypeMapped?.data?.map((e) => e.highlightText)?.toList() ?? [];
} catch (ex, tr) { } catch (ex, tr) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
} finally { } finally {}
//Utils.hideLoading(context);
}
setState(() {}); setState(() {});
//getAyaByRange();
} }
void getAyaByRange() async { void getAyaByRange() async {
Utils.showLoading(context); Utils.showLoading(context);
try { try {
_ayaModel = await TangheemUserApiClient().getAyaByFilter(_selectedSurah + 1, _fromAyaList[_selectedFromAya], _toAyaList[_selectedToAya]); _ayaModel = await TangheemUserApiClient().getAyaByFilter(_selectedSurah + 1, _fromAyaList[_selectedFromAya], _toAyaList[_selectedToAya]);
//setState(() {});
} catch (ex, tr) { } catch (ex, tr) {
Utils.handleException(ex, null); Utils.handleException(ex, null);
} finally { } finally {
@ -291,15 +278,6 @@ class _QuranScreenState extends State<QuranScreen> {
} }
} }
}), }),
// SizedBox(width: 8),
// commonIconButton(
// "مسح البحث",
// "assets/icons/cancel.svg",
// (_selectedSurah == -1 || _selectedFromAya == -1 || _selectedToAya == -1)
// ? null
// : () {
// _clearFilterAndRefreshData();
// }),
], ],
), ),
SizedBox(height: 16), SizedBox(height: 16),
@ -340,56 +318,9 @@ class _QuranScreenState extends State<QuranScreen> {
Expanded( Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
child: RepaintBoundary( child: Padding(
key: _globalKey, padding: EdgeInsets.only(left: 4, right: 4),
child: Material( child: quranText(),
color: Colors.white,
child: ListView(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: EdgeInsets.only(top: 16, bottom: 8),
children: [
// Text(
// "بسم الله الرحمن الرحيم",
// textAlign: TextAlign.center,
// style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: ColorConsts.primaryBlue, height: 1),
// ),
// SizedBox(height: 8),
Container(padding: EdgeInsets.only(left: 4, right: 4), child: quranText()
// Text(
// _surahAya,
// textAlign: TextAlign.center,
// style: TextStyle(
// fontFamily: "UthmanicHafs",
// fontSize: 18,
// color: ColorConsts.primaryBlue,
// fontWeight: FontWeight.bold,
// ),
// ),
// todo "sikander" : lines commented for future
// TextHighLightWidget(
// text: _surahAya,
// valueColor: ColorConsts.primaryBlue,
// highLightColor: ColorConsts.primaryBlue,
// highlights: _tangheemWords,
// onTap: (value) {
// List<AyatTangheemTypeMappedData> _ayatList = _ayatTangheemTypeMapped.data?.where((element) => element.highlightText == value)?.toList() ?? [];
// if (_ayatList.length > 1) {
// _selectTangheemType(_ayatList);
// } else {
// Navigator.pushNamed(context, TangheemDetailScreen.routeName, arguments: _ayatList.first);
// }
// },
// style: TextStyle(
// fontFamily: "UthmanicHafs",
// fontSize: 18,
// fontWeight: FontWeight.bold,
// ),
// ),
),
],
),
),
), ),
), ),
), ),
@ -421,7 +352,6 @@ class _QuranScreenState extends State<QuranScreen> {
), ),
), ),
), ),
// AyaPlayerWidget(surahName: _surahList.isNotEmpty ? _surahList[_selectedSurah] : "", globalKey: _globalKey)
], ],
), ),
); );
@ -635,7 +565,6 @@ class _QuranScreenState extends State<QuranScreen> {
Navigator.pop(context); Navigator.pop(context);
var temp = _bookMark.firstWhere((element) => element.ayahID == _selectedAyaForBookmark.ayahID, orElse: () => null); var temp = _bookMark.firstWhere((element) => element.ayahID == _selectedAyaForBookmark.ayahID, orElse: () => null);
if (temp != null) { if (temp != null) {
//
Utils.showToast("هذه الأية مضافة سابقا"); Utils.showToast("هذه الأية مضافة سابقا");
return; return;
} }

@ -21,8 +21,6 @@ import 'login_screen.dart';
class TangheemDetailScreen extends StatefulWidget { class TangheemDetailScreen extends StatefulWidget {
static const String routeName = "/tangheem_detail"; static const String routeName = "/tangheem_detail";
final List<AyatTangheemTypeMappedData> ayatTangheemTypeMappedDataList; final List<AyatTangheemTypeMappedData> ayatTangheemTypeMappedDataList;
// final AyatTangheemTypeMappedData ayatTangheemTypeMappedData;
TangheemDetailScreen({Key key, this.ayatTangheemTypeMappedDataList}) : super(key: key); TangheemDetailScreen({Key key, this.ayatTangheemTypeMappedDataList}) : super(key: key);
@override @override
@ -169,7 +167,6 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
_ayatTangheemTypeMappedData?.property?.where((element) => (element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? []; _ayatTangheemTypeMappedData?.property?.where((element) => (element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
_tangheemInsideTableValueList = _tangheemInsideTableValueList =
_ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? []; _ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? [];
// _tangheemInsideTableEmptyList = _ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isEmpty)?.toList() ?? [];
return ListView( return ListView(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
@ -461,7 +458,6 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
}, },
); );
// set up the AlertDialog
AlertDialog alert = AlertDialog( AlertDialog alert = AlertDialog(
content: Text("هذه الخاصية متاحه فقط للأعضاء المسجلين"), content: Text("هذه الخاصية متاحه فقط للأعضاء المسجلين"),
actions: [ actions: [
@ -470,7 +466,6 @@ class _TangheemDetailScreenState extends State<TangheemDetailScreen> {
], ],
); );
// show the dialog
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {

@ -37,8 +37,6 @@ class _AyaPlayerWidgetState extends State<AyaPlayerWidget> {
AudioPlayer _player; AudioPlayer _player;
bool _isAudioHaveError = false; bool _isAudioHaveError = false;
int _currentVoiceNote = -1;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -48,18 +46,12 @@ class _AyaPlayerWidgetState extends State<AyaPlayerWidget> {
setAudioSource() { setAudioSource() {
try { try {
// final _playlist = ConcatenatingAudioSource(children: [
// AudioSource.uri(
// Uri.parse("https://server6.mp3quran.net/thubti/109.mp3"),
// ),
// ]);
List<AudioSource> voiceList = []; List<AudioSource> voiceList = [];
if ((widget.voiceNoteList?.length ?? 0) > 0) { if ((widget.voiceNoteList?.length ?? 0) > 0) {
voiceList = widget.voiceNoteList.map((e) => AudioSource.uri(Uri.parse(e.exposeFilePath))).toList(); voiceList = widget.voiceNoteList.map((e) => AudioSource.uri(Uri.parse(e.exposeFilePath))).toList();
// _currentVoiceNote = 0;
} }
// voiceList = [AudioSource.uri(Uri.parse(widget.voiceNoteList.first.exposeFilePath))];
final _playlist = ConcatenatingAudioSource(children: voiceList); final _playlist = ConcatenatingAudioSource(children: voiceList);
_player.setAudioSource(_playlist, initialIndex: 0, initialPosition: Duration.zero).then((value) => () {}); _player.setAudioSource(_playlist, initialIndex: 0, initialPosition: Duration.zero).then((value) => () {});
} catch (e) { } catch (e) {

@ -18,7 +18,6 @@ class CommonTextFieldWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
// height: 50,
child: TextField( child: TextField(
textAlignVertical: TextAlignVertical.center, textAlignVertical: TextAlignVertical.center,
controller: controller, controller: controller,

@ -81,7 +81,6 @@ class OTPWidget extends StatefulWidget {
class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixin { class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixin {
AnimationController _highlightAnimationController; AnimationController _highlightAnimationController;
Animation _highlightAnimationColorTween;
FocusNode focusNode; FocusNode focusNode;
String text = ""; String text = "";
int currentIndex = 0; int currentIndex = 0;

Loading…
Cancel
Save