Enable search ui and search parameter added.

development
Sikander Saleem 5 years ago
parent 834a05e58a
commit 5790adf6d2

@ -53,9 +53,18 @@ class TangheemUserApiClient {
return await ApiClient().postJsonForObject((json) => TangheemType.fromJson(json), url, postParams);
}
Future<AyatTangheemTypeMapped> getAyaTangheemTypeMapped(int surahNo, String tangheemTypeName) async {
Future<AyatTangheemTypeMapped> getAyaTangheemTypeMapped(int surahNo, String tangheemTypeName, String ayaText) async {
String url = "${ApiConsts.tangheemUsers}AyatTangheemTypeMapped_Get";
var postParams = {"surahNo": surahNo, "tangheemTypeName": tangheemTypeName};
var postParams = {};
if (surahNo != null) {
postParams["surahNo"] = surahNo;
}
if (tangheemTypeName != null) {
postParams["tangheemTypeName"] = tangheemTypeName;
}
if (ayaText != null) {
postParams["ayaText"] = ayaText;
}
return await ApiClient().postJsonForObject((json) => AyatTangheemTypeMapped.fromJson(json), url, postParams);
}

@ -49,6 +49,7 @@ class Application extends StatelessWidget {
child: TangheemScreen(
surah: data["surahData"],
tangheemTypeName: data["tangheemTypeName"],
tangheemQuery: data["tangheemQuery"],
),
);
break;

@ -157,56 +157,56 @@ class _HomeScreenState extends State<HomeScreen> {
),
),
SizedBox(height: 16),
// todo "Sikander" : hide this search ui, later when we have search requirement, then visible this ui.
Visibility(
visible: false,
child: Container(
height: 50,
padding: EdgeInsets.only(top: 4, bottom: 6),
child: TextField(
controller: _searchController,
focusNode: _searchFocusNode,
style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 14),
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(4, 4, 4, 4),
alignLabelWithHint: true,
fillColor: Colors.white,
filled: true,
hintStyle: TextStyle(color: ColorConsts.textHintGrey, fontSize: 12),
hintText: "البحث عن سورة أو آية",
prefixIconConstraints: BoxConstraints(maxHeight: 16),
prefixIcon: Padding(
padding: EdgeInsets.only(right: 6),
child: SvgPicture.asset("assets/icons/search.svg"),
),
suffixIcon: InkWell(
onTap: () async {
_searchFocusNode.unfocus();
_searchFocusNode.canRequestFocus = false;
await Navigator.pushNamed(context, QuranScreen.routeName, arguments: _searchController.text);
_searchFocusNode.canRequestFocus = true;
},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: Container(
alignment: Alignment.center,
width: 80,
child: Text(
"بحث",
style: TextStyle(fontSize: 14, color: Colors.white),
),
decoration: BoxDecoration(
color: ColorConsts.secondaryPink,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(6),
topLeft: Radius.circular(6),
),
Container(
height: 50,
padding: EdgeInsets.only(top: 4, bottom: 6),
child: TextField(
controller: _searchController,
focusNode: _searchFocusNode,
style: TextStyle(color: ColorConsts.primaryBlack, fontSize: 14),
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(4, 4, 4, 4),
alignLabelWithHint: true,
fillColor: Colors.white,
filled: true,
hintStyle: TextStyle(color: ColorConsts.textHintGrey, fontSize: 12),
hintText: "البحث عن سورة أو آية",
prefixIconConstraints: BoxConstraints(maxHeight: 16),
prefixIcon: Padding(
padding: EdgeInsets.only(right: 6),
child: SvgPicture.asset("assets/icons/search.svg"),
),
suffixIcon: InkWell(
onTap: () async {
_searchFocusNode.unfocus();
if (_searchController.text.length < 1) {
Utils.showToast("يجب إدخال بعض الكلمات للبحث");
return;
}
_searchFocusNode.canRequestFocus = false;
var data = {"tangheemQuery": _searchController.text};
await Navigator.pushNamed(context, TangheemScreen.routeName, arguments: data);
_searchFocusNode.canRequestFocus = true;
},
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: Container(
alignment: Alignment.center,
width: 80,
child: Text(
"بحث",
style: TextStyle(fontSize: 14, color: Colors.white),
),
decoration: BoxDecoration(
color: ColorConsts.secondaryPink,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(6),
topLeft: Radius.circular(6),
),
),
),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(6), borderSide: BorderSide.none),
),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(6), borderSide: BorderSide.none),
),
),
)

@ -11,9 +11,10 @@ import 'package:tangheem/widgets/text_highlight_widget.dart';
class TangheemScreen extends StatefulWidget {
static const String routeName = "/tangheem";
final tangheemTypeName;
final String tangheemQuery;
final String tangheemTypeName;
final SurahModelData surah;
TangheemScreen({Key key, this.surah, this.tangheemTypeName}) : super(key: key);
TangheemScreen({Key key, this.surah, this.tangheemQuery, this.tangheemTypeName}) : super(key: key);
@override
_TangheemScreenState createState() {
@ -23,6 +24,7 @@ class TangheemScreen extends StatefulWidget {
class _TangheemScreenState extends State<TangheemScreen> {
AyatTangheemTypeMapped _ayatTangheemTypeMapped;
List<AyatTangheemTypeMappedData> _dataList;
@override
void initState() {
@ -33,7 +35,7 @@ class _TangheemScreenState extends State<TangheemScreen> {
void getTangheemData() async {
Utils.showLoading(context);
try {
_ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah.surahID, widget.tangheemTypeName);
_ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah?.surahID, widget.tangheemTypeName, widget.tangheemQuery);
_dataList = _ayatTangheemTypeMapped?.data ?? [];
} catch (ex, tr) {
_dataList = [];
@ -49,8 +51,6 @@ class _TangheemScreenState extends State<TangheemScreen> {
super.dispose();
}
List<AyatTangheemTypeMappedData> _dataList;
@override
Widget build(BuildContext context) {
return _dataList == null

Loading…
Cancel
Save