Limit loaded and less that 2 lakhs
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:kmobile/api/services/limit_service.dart';
|
||||
import 'package:kmobile/app.dart';
|
||||
import 'package:kmobile/di/injection.dart';
|
||||
import 'package:kmobile/l10n/app_localizations.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -43,63 +42,74 @@ class _DailyLimitScreenState extends State<DailyLimitScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _showAddOrEditLimitDialog() async {
|
||||
_limitController.text = _currentLimit?.toStringAsFixed(0) ?? '';
|
||||
final newLimit = await showDialog<double>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
final localizations = AppLocalizations.of(context);
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
_currentLimit == null
|
||||
? localizations.addLimit
|
||||
: localizations.editLimit,
|
||||
),
|
||||
content: TextField(
|
||||
controller: _limitController,
|
||||
autofocus: true,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d+')),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
labelText: localizations.limitAmount,
|
||||
prefixText: '₹',
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(localizations.cancel),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final value = double.tryParse(_limitController.text);
|
||||
if (value != null && value > 0) {
|
||||
setState(() {
|
||||
service.editLimit(value);
|
||||
});
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const NavigationScaffold(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Text(localizations.save),
|
||||
),
|
||||
Future<void> _showAddOrEditLimitDialog() async {
|
||||
_limitController.text = _currentLimit?.toStringAsFixed(0) ?? '';
|
||||
final newLimit = await showDialog<double>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
final localizations = AppLocalizations.of(dialogContext);
|
||||
final theme = Theme.of(dialogContext);
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
_currentLimit == null
|
||||
? localizations.addLimit
|
||||
: localizations.editLimit,
|
||||
),
|
||||
content: TextField(
|
||||
controller: _limitController,
|
||||
autofocus: true,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'^\d+')),
|
||||
],
|
||||
);
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
labelText: localizations.limitAmount,
|
||||
prefixText: '₹',
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: Text(localizations.cancel),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
final value = double.tryParse(_limitController.text);
|
||||
if (value == null || value <= 0) return;
|
||||
|
||||
if (value > 200000) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text("Limit To be Set must be less than 200000"),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: theme.colorScheme.error,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
service.editLimit(value);
|
||||
Navigator.of(dialogContext).pop(value);
|
||||
}
|
||||
},
|
||||
child: Text(localizations.save),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (newLimit != null) {
|
||||
_loadlimits();
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text("Limit Updated"),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
),
|
||||
);
|
||||
if (newLimit != null) {
|
||||
setState(() {
|
||||
_currentLimit = newLimit;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _removeLimit() {
|
||||
setState(() {
|
||||
|
||||
Reference in New Issue
Block a user