Daily Transaction Limit #2
This commit is contained in:
@@ -1,24 +1,160 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:kmobile/l10n/app_localizations.dart';
|
import 'package:kmobile/l10n/app_localizations.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
class DailyLimitScreen extends StatefulWidget {
|
class DailyLimitScreen extends StatefulWidget {
|
||||||
const DailyLimitScreen({super.key});
|
const DailyLimitScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DailyLimitScreen> createState() => _DailyLimitScreenState();
|
State<DailyLimitScreen> createState() => _DailyLimitScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DailyLimitScreenState extends State<DailyLimitScreen> {
|
class _DailyLimitScreenState extends State<DailyLimitScreen> {
|
||||||
|
double? _currentLimit;
|
||||||
|
final _limitController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
// Now just taking null, but for real time limit will be fetched using API call
|
||||||
|
_currentLimit = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_limitController.dispose();
|
||||||
|
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: () {
|
||||||
|
final value = double.tryParse(_limitController.text);
|
||||||
|
if (value != null && value > 0) {
|
||||||
|
Navigator.of(context).pop(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Text(localizations.save),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (newLimit != null) {
|
||||||
|
setState(() {
|
||||||
|
_currentLimit = newLimit;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _removeLimit() {
|
||||||
|
setState(() {
|
||||||
|
_currentLimit = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final localizations = AppLocalizations.of(context);
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
final formatCurrency = NumberFormat.currency(locale: 'en_IN', symbol: '₹');
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(AppLocalizations.of(context).dailylimit),
|
title: Text(localizations.dailylimit),
|
||||||
|
),
|
||||||
|
body: Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
localizations.currentDailyLimit,
|
||||||
|
style: theme.textTheme.headlineSmall?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurface.withOpacity(0.7),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
_currentLimit == null
|
||||||
|
? localizations.noLimitSet
|
||||||
|
: formatCurrency.format(_currentLimit),
|
||||||
|
style: theme.textTheme.headlineMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: _currentLimit == null
|
||||||
|
? theme.colorScheme.secondary
|
||||||
|
: theme.colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 48),
|
||||||
|
if (_currentLimit == null)
|
||||||
|
ElevatedButton.icon(
|
||||||
|
onPressed: _showAddOrEditLimitDialog,
|
||||||
|
icon: const Icon(Icons.add_circle_outline),
|
||||||
|
label: Text(localizations.addLimit),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24, vertical: 12),
|
||||||
|
textStyle: theme.textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
ElevatedButton.icon(
|
||||||
|
onPressed: _showAddOrEditLimitDialog,
|
||||||
|
icon: const Icon(Icons.edit_outlined),
|
||||||
|
label: Text(localizations.editLimit),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 24, vertical: 12),
|
||||||
|
textStyle: theme.textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: _removeLimit,
|
||||||
|
icon: const Icon(Icons.remove_circle_outline),
|
||||||
|
label: Text(localizations.removeLimit),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: theme.colorScheme.error,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,5 +319,12 @@
|
|||||||
"faq": "Frequently Asked Questions(FAQs)",
|
"faq": "Frequently Asked Questions(FAQs)",
|
||||||
"branches": "Branches",
|
"branches": "Branches",
|
||||||
"atms": "ATMs",
|
"atms": "ATMs",
|
||||||
"dailylimit": "Daily Transaction Limit"
|
"dailylimit": "Daily Transaction Limit",
|
||||||
|
"currentDailyLimit": "Current Daily Limit",
|
||||||
|
"noLimitSet": "No Limit Set",
|
||||||
|
"addLimit": "Add Limit",
|
||||||
|
"editLimit": "Edit Limit",
|
||||||
|
"removeLimit": "Remove Limit",
|
||||||
|
"limitAmount": "Limit Amount",
|
||||||
|
"save": "Save"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,7 +318,14 @@
|
|||||||
"remarks": "विचार (अनिवार्य नहीं)",
|
"remarks": "विचार (अनिवार्य नहीं)",
|
||||||
"kccbMobile": "केसीसीबी मोबाइल",
|
"kccbMobile": "केसीसीबी मोबाइल",
|
||||||
"faq": "अक्सर पूछे जाने वाले प्रश्न",
|
"faq": "अक्सर पूछे जाने वाले प्रश्न",
|
||||||
"branches": "शाखाओं",
|
"branches": "शाखाओं",
|
||||||
"atms": "एटीएम",
|
"atms": "एटीएम",
|
||||||
"dailylimit": "दैनिक लेनदेन सीमा"
|
"dailylimit": "दैनिक लेनदेन सीमा",
|
||||||
|
"currentDailyLimit": "वर्तमान दैनिक सीमा",
|
||||||
|
"noLimitSet": "कोई सीमा निर्धारित नहीं",
|
||||||
|
"addLimit": "सीमा जोड़ें",
|
||||||
|
"editLimit": "सीमा संपादित करें",
|
||||||
|
"removeLimit": "सीमा हटाएँ",
|
||||||
|
"limitAmount": "सीमा राशि",
|
||||||
|
"save": "जमा करें"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user