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),
),
),
// color: Const.primaryBlue,
child: CommonTextFieldWidget(hint: "البحث في البلد", controller: _searchCountryController),
),
Expanded(

@ -243,10 +243,8 @@ class _CommonAppbarState extends State<CommonAppbar> {
}),
),
Container(
// width: 35,
height: 40,
margin: EdgeInsets.only(right: 17, left: 10),
// color: Const.primaryBlack,
child: VerticalDivider(color: ColorConsts.primaryBlack, thickness: .7, width: 1),
),
],
@ -281,7 +279,6 @@ class _CommonAppbarState extends State<CommonAppbar> {
),
SizedBox(width: 8),
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),
),
Container(
// width: double.infinity,
margin: EdgeInsets.only(top: 8, bottom: 8),
padding: EdgeInsets.all(6),
decoration: BoxDecoration(
// color: Colors.white,
border: Border.all(width: 1, color: Colors.white),
),
child: OTPWidget(

@ -37,15 +37,9 @@ class _BookmarkScreenState extends State<BookmarkScreen> {
}
void handleSlideAnimationChanged(Animation<double> slideAnimation) {
// setState(() {
// _rotationAnimation = slideAnimation;
// });
}
void handleSlideIsOpenChanged(bool isOpen) {
// setState(() {
// _fabColor = isOpen! ? Colors.green : Colors.blue;
// });
}
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/utils.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/otp_dialog.dart';
import 'package:tangheem/widgets/common_textfield_widget.dart';
@ -22,7 +21,6 @@ class ForgotPasswordScreen extends StatefulWidget {
class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
TextEditingController _emailController = TextEditingController();
GeneralResponseModel _generalResponse;
@override
void initState() {
@ -37,7 +35,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
void forgotPassword(String email) async {
Utils.showLoading(context);
try {
_generalResponse = await UserApiClient().forgotPassword(email);
await UserApiClient().forgotPassword(email);
Utils.showToast("تم إرسال OTP");
} catch (ex, tr) {
Utils.handleException(ex, null);
@ -52,7 +50,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
void verifyOTP(String email, int otp) async {
Utils.showLoading(context);
try {
_generalResponse = await UserApiClient().verifyOTP(email, otp);
await UserApiClient().verifyOTP(email, otp);
} catch (ex, tr) {
Utils.handleException(ex, null);
Utils.hideLoading(context);
@ -67,7 +65,7 @@ class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
void updatePassword(String email, int otp, String password) async {
Utils.showLoading(context);
try {
_generalResponse = await UserApiClient().updatePassword(email, otp, password);
await UserApiClient().updatePassword(email, otp, password);
} catch (ex, tr) {
Utils.handleException(ex, null);
Utils.hideLoading(context);

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

@ -31,7 +31,6 @@ class QuranScreen extends StatefulWidget {
}
class _QuranScreenState extends State<QuranScreen> {
GlobalKey _globalKey = GlobalKey();
int _selectedSurah = -1;
int _selectedFromAya = -1;
int _selectedToAya = -1;
@ -81,9 +80,7 @@ class _QuranScreenState extends State<QuranScreen> {
}
_surahList = _surahModel.data.map((element) => element.nameAR).toList();
_currentPage = widget.bookmark?.page ?? 1;
Utils.hideLoading(context);
//filterData();
} catch (ex, tr) {
Utils.hideLoading(context);
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() ?? [];
_fromAyaList = filteredAyahList.getRange(0, filteredAyahList.length - 1)?.toList() ?? [];
// _toAyaList = filteredAyahList.getRange(1, filteredAyahList.length)?.toList() ?? [];
// _currentPage = 0;
// _selectedFromAya = 0;
// _selectedToAya = 0;
setState(() {});
// getTangheemBySurahId();
}
void getTangheemBySurahId() async {
//Utils.showLoading(context);
try {
_ayatTangheemTypeMapped = await TangheemUserApiClient().getTangheemBySurah(_selectedSurah + 1);
_tangheemWords = _ayatTangheemTypeMapped?.data?.map((e) => e.highlightText)?.toList() ?? [];
} catch (ex, tr) {
Utils.handleException(ex, null);
} finally {
//Utils.hideLoading(context);
}
} finally {}
setState(() {});
//getAyaByRange();
}
void getAyaByRange() async {
Utils.showLoading(context);
try {
_ayaModel = await TangheemUserApiClient().getAyaByFilter(_selectedSurah + 1, _fromAyaList[_selectedFromAya], _toAyaList[_selectedToAya]);
//setState(() {});
} catch (ex, tr) {
Utils.handleException(ex, null);
} 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),
@ -340,56 +318,9 @@ class _QuranScreenState extends State<QuranScreen> {
Expanded(
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: RepaintBoundary(
key: _globalKey,
child: Material(
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,
// ),
// ),
),
],
),
),
child: Padding(
padding: EdgeInsets.only(left: 4, right: 4),
child: quranText(),
),
),
),
@ -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);
var temp = _bookMark.firstWhere((element) => element.ayahID == _selectedAyaForBookmark.ayahID, orElse: () => null);
if (temp != null) {
//
Utils.showToast("هذه الأية مضافة سابقا");
return;
}

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

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

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

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

Loading…
Cancel
Save