update discount
This commit is contained in:
@@ -85,7 +85,8 @@ class _InvitationCreateState extends State<InvitationCreate> {
|
|||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: Colors.grey.shade400, width: 1),
|
border:
|
||||||
|
Border.all(color: Colors.grey.shade400, width: 1),
|
||||||
borderRadius: BorderRadius.all(Radius.circular(12.0))),
|
borderRadius: BorderRadius.all(Radius.circular(12.0))),
|
||||||
child: CountryCodePicker(
|
child: CountryCodePicker(
|
||||||
onChanged: _countryChange,
|
onChanged: _countryChange,
|
||||||
@@ -94,9 +95,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
|
|||||||
showCountryOnly: false,
|
showCountryOnly: false,
|
||||||
showOnlyCountryWhenClosed: false,
|
showOnlyCountryWhenClosed: false,
|
||||||
alignLeft: false,
|
alignLeft: false,
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(fontSize: 16, color: Colors.black87),
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -172,7 +171,7 @@ class _InvitationCreateState extends State<InvitationCreate> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isDataChanged() {
|
isDataChanged() {
|
||||||
String userName = _nameController.text;
|
String userName = _nameController.text;
|
||||||
String phoneNumber = _phoneController.text;
|
String phoneNumber = _phoneController.text;
|
||||||
return userName != "" || phoneNumber != "";
|
return userName != "" || phoneNumber != "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ class DiscountModel extends BaseModel {
|
|||||||
StreamSubscription<QuerySnapshot>? listener;
|
StreamSubscription<QuerySnapshot>? listener;
|
||||||
|
|
||||||
List<Discount> _discounts = [];
|
List<Discount> _discounts = [];
|
||||||
List<Discount> get discounts =>
|
List<Discount> get discounts => _selectedIndex == 1
|
||||||
_selectedIndex == 1 ? _discounts : List<Discount>.from(_used.values);
|
? _discounts
|
||||||
|
: List<Discount>.from(_used?.values ?? []);
|
||||||
|
|
||||||
late Paginator _used;
|
Paginator? _used;
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
int _selectedIndex = 1;
|
int _selectedIndex = 1;
|
||||||
set selectedIndex(int index) {
|
set selectedIndex(int index) {
|
||||||
@@ -31,7 +32,7 @@ class DiscountModel extends BaseModel {
|
|||||||
_selectedIndex = 1;
|
_selectedIndex = 1;
|
||||||
_load();
|
_load();
|
||||||
if (_getUsed() != null) _used = _getUsed();
|
if (_getUsed() != null) _used = _getUsed();
|
||||||
_used.load();
|
_used?.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initUser(user) {
|
void initUser(user) {
|
||||||
@@ -49,8 +50,7 @@ class DiscountModel extends BaseModel {
|
|||||||
.listen((snaps) {
|
.listen((snaps) {
|
||||||
_discounts.clear();
|
_discounts.clear();
|
||||||
snaps.docs.forEach((d) {
|
snaps.docs.forEach((d) {
|
||||||
_discounts
|
_discounts.add(Discount.fromMap(d.data(), d.id));
|
||||||
.add(Discount.fromMap(d.data() as Map<String, dynamic>, d.id));
|
|
||||||
});
|
});
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
@@ -94,10 +94,10 @@ class DiscountModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadMore() async {
|
Future<void> loadMore() async {
|
||||||
if (_used.ended || _selectedIndex == 1) return;
|
if (_used!.ended || _selectedIndex == 1) return;
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await _used.load(onFinished: () {
|
await _used!.load(onFinished: () {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
@@ -105,7 +105,7 @@ class DiscountModel extends BaseModel {
|
|||||||
|
|
||||||
Future<void> refresh() async {
|
Future<void> refresh() async {
|
||||||
if (_selectedIndex == 1) return;
|
if (_selectedIndex == 1) return;
|
||||||
await _used.refresh(onFinished: () {
|
await _used!.refresh(onFinished: () {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ class DiscountModel extends BaseModel {
|
|||||||
@override
|
@override
|
||||||
logout() async {
|
logout() async {
|
||||||
if (listener != null) await listener!.cancel();
|
if (listener != null) await listener!.cancel();
|
||||||
if (_used != null) _used.close();
|
if (_used != null) _used!.close();
|
||||||
|
|
||||||
_discounts = [];
|
_discounts = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,9 +90,7 @@ class _SigninPageState extends State<SigninPage> {
|
|||||||
showCountryOnly: false,
|
showCountryOnly: false,
|
||||||
showOnlyCountryWhenClosed: false,
|
showOnlyCountryWhenClosed: false,
|
||||||
alignLeft: false,
|
alignLeft: false,
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(fontSize: 16, color: Colors.black87),
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|||||||
Reference in New Issue
Block a user