2024-05-06 17:28:10 +02:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_application_1/enums.dart';
|
2024-06-03 12:46:40 +02:00
|
|
|
import 'package:flutter_application_1/utils.dart';
|
2024-05-06 17:28:10 +02:00
|
|
|
|
|
|
|
class IntervalWidget extends StatefulWidget {
|
|
|
|
final String selectedInterval;
|
|
|
|
final Function(String) onChanged;
|
|
|
|
|
2024-05-24 14:04:26 +02:00
|
|
|
const IntervalWidget({
|
|
|
|
super.key,
|
|
|
|
required this.selectedInterval,
|
|
|
|
required this.onChanged
|
|
|
|
});
|
2024-05-06 17:28:10 +02:00
|
|
|
|
|
|
|
@override
|
2024-05-24 14:04:26 +02:00
|
|
|
IntervalWidgetState createState() => IntervalWidgetState();
|
2024-05-06 17:28:10 +02:00
|
|
|
}
|
|
|
|
|
2024-05-24 14:04:26 +02:00
|
|
|
class IntervalWidgetState extends State<IntervalWidget> {
|
|
|
|
bool isExpanded = false; // Zustand, ob das Intervall-Auswahlfenster erweitert ist
|
2024-05-06 17:28:10 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
const Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'Ausschüttungsintervall',
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(width: 5),
|
2024-05-24 14:04:26 +02:00
|
|
|
// Tooltip mit Erklärung zum Ausschüttungsintervall
|
2024-05-06 17:28:10 +02:00
|
|
|
Tooltip(
|
|
|
|
message: 'Das Ausschüttungsintervall bezieht sich darauf, wie oft die Erträge aus Ihrer Investition ausgeschüttet werden.',
|
2024-05-20 16:34:31 +02:00
|
|
|
triggerMode: TooltipTriggerMode.tap,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: CupertinoColors.black,
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(5))
|
|
|
|
),
|
|
|
|
textStyle: TextStyle(
|
|
|
|
color: CupertinoColors.white,
|
|
|
|
),
|
|
|
|
margin: EdgeInsets.all(20),
|
2024-05-06 17:28:10 +02:00
|
|
|
child: Icon(CupertinoIcons.question_circle_fill, size: 15),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
),
|
|
|
|
CupertinoTextField(
|
|
|
|
placeholder: 'Ausschüttungsintervall auswählen',
|
|
|
|
readOnly: true,
|
|
|
|
onTap: () {
|
2024-05-24 14:04:26 +02:00
|
|
|
// Öffnet das ModalBottomSheet zur Auswahl des Ausschüttungsintervalls
|
2024-05-06 17:28:10 +02:00
|
|
|
showModalBottomSheet(
|
|
|
|
context: context,
|
2024-05-24 14:04:26 +02:00
|
|
|
backgroundColor: CupertinoColors.black,
|
2024-05-06 17:28:10 +02:00
|
|
|
builder: (BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
2024-05-24 14:04:26 +02:00
|
|
|
// ListTile für jährliches Ausschüttungsintervall
|
2024-05-06 17:28:10 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
|
|
|
translateInterval(PayoutInterval.yearly),
|
|
|
|
style: const TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
2024-05-24 14:04:26 +02:00
|
|
|
color: CupertinoColors.white,
|
2024-05-06 17:28:10 +02:00
|
|
|
),
|
|
|
|
),
|
2024-05-24 14:04:26 +02:00
|
|
|
trailing: widget.selectedInterval == translateInterval(PayoutInterval.yearly) ? const Icon(CupertinoIcons.checkmark_alt, color: CupertinoColors.white,) : null,
|
2024-05-06 17:28:10 +02:00
|
|
|
onTap: () {
|
|
|
|
widget.onChanged(translateInterval(PayoutInterval.yearly));
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2024-05-24 14:04:26 +02:00
|
|
|
// ListTile für monatliches Ausschüttungsintervall
|
2024-05-06 17:28:10 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
|
|
|
child: ListTile(
|
|
|
|
title: Text(
|
|
|
|
translateInterval(PayoutInterval.monthly),
|
|
|
|
style: const TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
2024-05-24 14:04:26 +02:00
|
|
|
color: CupertinoColors.white,
|
2024-05-06 17:28:10 +02:00
|
|
|
),
|
|
|
|
),
|
2024-05-24 14:04:26 +02:00
|
|
|
trailing: widget.selectedInterval == translateInterval(PayoutInterval.monthly) ? const Icon(CupertinoIcons.checkmark_alt, color: CupertinoColors.white,) : null,
|
2024-05-06 17:28:10 +02:00
|
|
|
onTap: () {
|
|
|
|
widget.onChanged(translateInterval(PayoutInterval.monthly));
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
).then((value) {
|
|
|
|
setState(() {
|
2024-05-24 14:04:26 +02:00
|
|
|
isExpanded = false; // Setzt den Zustand auf nicht erweitert zurück, wenn das Modal geschlossen wird
|
2024-05-06 17:28:10 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
setState(() {
|
2024-05-24 14:04:26 +02:00
|
|
|
isExpanded = true; // Setzt den Zustand auf erweitert
|
2024-05-06 17:28:10 +02:00
|
|
|
});
|
|
|
|
},
|
2024-05-24 14:04:26 +02:00
|
|
|
// Suffix-Icon, das den Zustand anzeigt (erweitert oder nicht)
|
2024-05-06 17:28:10 +02:00
|
|
|
suffix: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 5.0),
|
|
|
|
child: Icon(isExpanded ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down),
|
|
|
|
),
|
2024-05-24 14:04:26 +02:00
|
|
|
controller: TextEditingController(text: widget.selectedInterval), // Setzt den Text des Textfeldes auf das ausgewählte Intervall
|
2024-05-06 17:28:10 +02:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: CupertinoColors.extraLightBackgroundGray,
|
|
|
|
borderRadius: BorderRadius.circular(5),
|
|
|
|
),
|
|
|
|
cursorColor: CupertinoColors.black,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|