dart format
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TncDialog extends StatefulWidget {
|
||||
final Future<void> Function() onProceed;
|
||||
class TncDialog extends StatefulWidget {
|
||||
final Future<void> Function() onProceed;
|
||||
|
||||
const TncDialog({Key? key, required this.onProceed}) : super(key: key);
|
||||
const TncDialog({Key? key, required this.onProceed}) : super(key: key);
|
||||
|
||||
@override
|
||||
_TncDialogState createState() => _TncDialogState();
|
||||
}
|
||||
@override
|
||||
_TncDialogState createState() => _TncDialogState();
|
||||
}
|
||||
|
||||
class _TncDialogState extends State<TncDialog> {
|
||||
bool _isAgreed = false;
|
||||
bool _isLoading = false;
|
||||
// --- NEW: ScrollController for the TNC text ---
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
class _TncDialogState extends State<TncDialog> {
|
||||
bool _isAgreed = false;
|
||||
bool _isLoading = false;
|
||||
// --- NEW: ScrollController for the TNC text ---
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
|
||||
final String _termsAndConditionsText = """
|
||||
final String _termsAndConditionsText = """
|
||||
Effective Date: November 10, 2025
|
||||
|
||||
These Terms and Conditions ("Terms") govern your access to and use of The Bank mobile banking application (the "App") and the services
|
||||
@@ -111,101 +111,101 @@
|
||||
access to or use of the App and Services.
|
||||
""";
|
||||
|
||||
void _handleProceed() async {
|
||||
if (_isLoading) return;
|
||||
void _handleProceed() async {
|
||||
if (_isLoading) return;
|
||||
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
|
||||
await widget.onProceed();
|
||||
await widget.onProceed();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose(); // --- NEW: Dispose the ScrollController ---
|
||||
super.dispose();
|
||||
}
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose(); // --- NEW: Dispose the ScrollController ---
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenSize = MediaQuery.of(context).size;
|
||||
|
||||
return AlertDialog(
|
||||
title: const Text('Terms and Conditions'),
|
||||
content: SizedBox(
|
||||
height: screenSize.height * 0.5, // 50% of screen height
|
||||
width: screenSize.width * 0.9, // 90% of screen width
|
||||
// --- MODIFIED: Use a Column to separate scrollable text from fixed checkbox ---
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// --- NEW: Expanded Scrollbar for the TNC text ---
|
||||
Expanded(
|
||||
child: Scrollbar(
|
||||
controller: _scrollController,
|
||||
thumbVisibility: true, // Always show the scrollbar thumb
|
||||
// To place the scrollbar on the left, you might need to wrap
|
||||
// this in a Directionality widget or use a custom scrollbar.
|
||||
// For now, it will appear on the right as is standard.
|
||||
child: SingleChildScrollView(
|
||||
controller: _scrollController,
|
||||
child: _isLoading
|
||||
? const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: Text(_termsAndConditionsText),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16), // Space between text and checkbox
|
||||
// --- MODIFIED: Checkbox Row is now outside the SingleChildScrollView ---
|
||||
Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: _isAgreed,
|
||||
onChanged: (bool? value) {
|
||||
setState(() {
|
||||
_isAgreed = value ?? false;
|
||||
});
|
||||
},
|
||||
),
|
||||
const Flexible(
|
||||
child: Text('I agree to the Terms and Conditions')),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'You must agree to the terms and conditions to proceed.'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('Disagree'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _isAgreed && !_isLoading ? _handleProceed : null,
|
||||
child: const Text('Proceed'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
return AlertDialog(
|
||||
title: const Text('Terms and Conditions'),
|
||||
content: SizedBox(
|
||||
height: screenSize.height * 0.5, // 50% of screen height
|
||||
width: screenSize.width * 0.9, // 90% of screen width
|
||||
// --- MODIFIED: Use a Column to separate scrollable text from fixed checkbox ---
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// --- NEW: Expanded Scrollbar for the TNC text ---
|
||||
Expanded(
|
||||
child: Scrollbar(
|
||||
controller: _scrollController,
|
||||
thumbVisibility: true, // Always show the scrollbar thumb
|
||||
// To place the scrollbar on the left, you might need to wrap
|
||||
// this in a Directionality widget or use a custom scrollbar.
|
||||
// For now, it will appear on the right as is standard.
|
||||
child: SingleChildScrollView(
|
||||
controller: _scrollController,
|
||||
child: _isLoading
|
||||
? const Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: Text(_termsAndConditionsText),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16), // Space between text and checkbox
|
||||
// --- MODIFIED: Checkbox Row is now outside the SingleChildScrollView ---
|
||||
Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: _isAgreed,
|
||||
onChanged: (bool? value) {
|
||||
setState(() {
|
||||
_isAgreed = value ?? false;
|
||||
});
|
||||
},
|
||||
),
|
||||
const Flexible(
|
||||
child: Text('I agree to the Terms and Conditions')),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'You must agree to the terms and conditions to proceed.'),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('Disagree'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _isAgreed && !_isLoading ? _handleProceed : null,
|
||||
child: const Text('Proceed'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user