download aya to device added, share aya added & play aya as audio added.
parent
ee5c9a9cd1
commit
a810086aef
@ -0,0 +1,65 @@
|
|||||||
|
class CountryModel {
|
||||||
|
int totalItemsCount;
|
||||||
|
int statusCode;
|
||||||
|
String message;
|
||||||
|
List<Data> data;
|
||||||
|
|
||||||
|
CountryModel(
|
||||||
|
{this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||||
|
|
||||||
|
CountryModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
statusCode = json['statusCode'];
|
||||||
|
message = json['message'];
|
||||||
|
if (json['data'] != null) {
|
||||||
|
data = new List<Data>();
|
||||||
|
json['data'].forEach((v) {
|
||||||
|
data.add(new Data.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
data['statusCode'] = this.statusCode;
|
||||||
|
data['message'] = this.message;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Data {
|
||||||
|
int countryId;
|
||||||
|
String countryCode;
|
||||||
|
String countryNameEn;
|
||||||
|
String countryNameAr;
|
||||||
|
String countryFlag;
|
||||||
|
|
||||||
|
Data(
|
||||||
|
{this.countryId,
|
||||||
|
this.countryCode,
|
||||||
|
this.countryNameEn,
|
||||||
|
this.countryNameAr,
|
||||||
|
this.countryFlag});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
countryId = json['countryId'];
|
||||||
|
countryCode = json['countryCode'];
|
||||||
|
countryNameEn = json['countryNameEn'];
|
||||||
|
countryNameAr = json['countryNameAr'];
|
||||||
|
countryFlag = json['countryFlag'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['countryId'] = this.countryId;
|
||||||
|
data['countryCode'] = this.countryCode;
|
||||||
|
data['countryNameEn'] = this.countryNameEn;
|
||||||
|
data['countryNameAr'] = this.countryNameAr;
|
||||||
|
data['countryFlag'] = this.countryFlag;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
class TangheemType {
|
||||||
|
int totalItemsCount;
|
||||||
|
int statusCode;
|
||||||
|
String message;
|
||||||
|
List<Data> data;
|
||||||
|
|
||||||
|
TangheemType(
|
||||||
|
{this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||||
|
|
||||||
|
TangheemType.fromJson(Map<String, dynamic> json) {
|
||||||
|
totalItemsCount = json['totalItemsCount'];
|
||||||
|
statusCode = json['statusCode'];
|
||||||
|
message = json['message'];
|
||||||
|
if (json['data'] != null) {
|
||||||
|
data = new List<Data>();
|
||||||
|
json['data'].forEach((v) {
|
||||||
|
data.add(new Data.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['totalItemsCount'] = this.totalItemsCount;
|
||||||
|
data['statusCode'] = this.statusCode;
|
||||||
|
data['message'] = this.message;
|
||||||
|
if (this.data != null) {
|
||||||
|
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Data {
|
||||||
|
String tangheemTypeId;
|
||||||
|
String tangheemTypeName;
|
||||||
|
bool isActive;
|
||||||
|
|
||||||
|
Data({this.tangheemTypeId, this.tangheemTypeName, this.isActive});
|
||||||
|
|
||||||
|
Data.fromJson(Map<String, dynamic> json) {
|
||||||
|
tangheemTypeId = json['tangheemTypeId'];
|
||||||
|
tangheemTypeName = json['tangheemTypeName'];
|
||||||
|
isActive = json['isActive'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['tangheemTypeId'] = this.tangheemTypeId;
|
||||||
|
data['tangheemTypeName'] = this.tangheemTypeName;
|
||||||
|
data['isActive'] = this.isActive;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:tangheem/classes/colors.dart';
|
||||||
|
import 'package:tangheem/models/country_model.dart';
|
||||||
|
import 'package:tangheem/widgets/common_textfield_widget.dart';
|
||||||
|
|
||||||
|
class CountrySelectionBottomSheet extends StatefulWidget {
|
||||||
|
final List<Data> countryList;
|
||||||
|
final Function(Data) onSelectCountry;
|
||||||
|
CountrySelectionBottomSheet({Key key, this.countryList, this.onSelectCountry}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CountrySelectionBottomSheetState createState() {
|
||||||
|
return _CountrySelectionBottomSheetState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CountrySelectionBottomSheetState extends State<CountrySelectionBottomSheet> {
|
||||||
|
TextEditingController _searchCountryController = TextEditingController();
|
||||||
|
List<Data> _filteredCountryList = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_searchCountryController.addListener(_onTextChange);
|
||||||
|
_filterList("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void _filterList(String _query) {
|
||||||
|
_filteredCountryList = [];
|
||||||
|
if (_query.isEmpty) {
|
||||||
|
_filteredCountryList = widget.countryList;
|
||||||
|
} else {
|
||||||
|
_filteredCountryList = widget.countryList.where((element) => element.countryNameAr.contains(_query) || element.countryNameEn.toLowerCase().contains(_query.toLowerCase()))?.toList() ?? [];
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onTextChange() {
|
||||||
|
var _searchText = _searchCountryController.text;
|
||||||
|
print("_searchText:$_searchText");
|
||||||
|
_filterList(_searchText);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Directionality(
|
||||||
|
textDirection: TextDirection.rtl,
|
||||||
|
child: Container(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.75,
|
||||||
|
padding: EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(16),
|
||||||
|
topRight: Radius.circular(16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: EdgeInsets.all(8),
|
||||||
|
height: 54,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorConsts.primaryBlue,
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(12),
|
||||||
|
topRight: Radius.circular(12),
|
||||||
|
bottomRight: Radius.circular(12),
|
||||||
|
bottomLeft: Radius.circular(12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// color: Const.primaryBlue,
|
||||||
|
child: CommonTextFieldWidget(hint: "البحث في البلد", controller: _searchCountryController),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.separated(
|
||||||
|
padding: EdgeInsets.only(left: 8, right: 8),
|
||||||
|
itemCount: _filteredCountryList.length,
|
||||||
|
physics: BouncingScrollPhysics(),
|
||||||
|
separatorBuilder: (context, index) => Divider(
|
||||||
|
height: 1,
|
||||||
|
color: Colors.black87.withOpacity(0.3),
|
||||||
|
),
|
||||||
|
itemBuilder: (context, index) => ListTile(
|
||||||
|
title: Text(_filteredCountryList[index].countryNameAr + " (" + _filteredCountryList[index].countryCode + ")"),
|
||||||
|
dense: true,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
widget.onSelectCountry(_filteredCountryList[index]);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue