Limit loaded and less that 2 lakhs
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:kmobile/api/services/limit_service.dart';
|
import 'package:kmobile/api/services/limit_service.dart';
|
||||||
import 'package:kmobile/app.dart';
|
|
||||||
import 'package:kmobile/di/injection.dart';
|
import 'package:kmobile/di/injection.dart';
|
||||||
import 'package:kmobile/l10n/app_localizations.dart';
|
import 'package:kmobile/l10n/app_localizations.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
@@ -47,8 +46,9 @@ class _DailyLimitScreenState extends State<DailyLimitScreen> {
|
|||||||
_limitController.text = _currentLimit?.toStringAsFixed(0) ?? '';
|
_limitController.text = _currentLimit?.toStringAsFixed(0) ?? '';
|
||||||
final newLimit = await showDialog<double>(
|
final newLimit = await showDialog<double>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (dialogContext) {
|
||||||
final localizations = AppLocalizations.of(context);
|
final localizations = AppLocalizations.of(dialogContext);
|
||||||
|
final theme = Theme.of(dialogContext);
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text(
|
title: Text(
|
||||||
_currentLimit == null
|
_currentLimit == null
|
||||||
@@ -70,22 +70,25 @@ class _DailyLimitScreenState extends State<DailyLimitScreen> {
|
|||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||||
child: Text(localizations.cancel),
|
child: Text(localizations.cancel),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () {
|
||||||
final value = double.tryParse(_limitController.text);
|
final value = double.tryParse(_limitController.text);
|
||||||
if (value != null && value > 0) {
|
if (value == null || value <= 0) return;
|
||||||
setState(() {
|
|
||||||
service.editLimit(value);
|
if (value > 200000) {
|
||||||
});
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
Navigator.push(
|
SnackBar(
|
||||||
context,
|
content: const Text("Limit To be Set must be less than 200000"),
|
||||||
MaterialPageRoute(
|
behavior: SnackBarBehavior.floating,
|
||||||
builder: (context) => const NavigationScaffold(),
|
backgroundColor: theme.colorScheme.error,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
service.editLimit(value);
|
||||||
|
Navigator.of(dialogContext).pop(value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(localizations.save),
|
child: Text(localizations.save),
|
||||||
@@ -94,13 +97,20 @@ class _DailyLimitScreenState extends State<DailyLimitScreen> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (newLimit != null) {
|
if (newLimit != null) {
|
||||||
setState(() {
|
_loadlimits();
|
||||||
_currentLimit = newLimit;
|
if (!mounted) return;
|
||||||
});
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text("Limit Updated"),
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _removeLimit() {
|
void _removeLimit() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentLimit = null;
|
_currentLimit = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user