|
|
- import 'package:flutter/material.dart';
-
- import '/components/custom_title_bar.dart';
-
- const Map<String, String> messageExpiryValues = {
- 'no_expiry': 'No Expiry',
- 'fifteen_min': '15 Minutes',
- 'thirty_min': '30 Minutes',
- 'one_hour': '1 Hour',
- 'three_hour': '3 Hours',
- 'six_hour': '6 Hours',
- 'twelve_day': '12 Hours',
- 'one_day': '1 Day',
- 'three_day': '3 Days',
- };
-
- class SelectMessageTTL extends StatefulWidget {
- const SelectMessageTTL({
- Key? key,
- required this.widgetTitle,
- required this.backCallback,
- this.currentSelected,
- }) : super(key: key);
-
- final String widgetTitle;
- final Future<void> Function(String messageExpiry) backCallback;
- final String? currentSelected;
-
- @override
- _SelectMessageTTLState createState() => _SelectMessageTTLState();
- }
-
- class _SelectMessageTTLState extends State<SelectMessageTTL> {
- String selectedExpiry = 'no_expiry';
-
- @override
- void initState() {
- selectedExpiry = widget.currentSelected ?? 'no_expiry';
- super.initState();
- }
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: CustomTitleBar(
- title: Text(
- widget.widgetTitle,
- style: const TextStyle(
- fontSize: 28,
- fontWeight: FontWeight.bold
- )
- ),
- showBack: true,
- backgroundColor: Colors.transparent,
- beforeBack: () async {
- widget.backCallback(selectedExpiry);
- },
- ),
- body: Padding(
- padding: const EdgeInsets.only(top: 30),
- child: _list(),
- ),
- );
- }
-
- Widget _list() {
- return ListView.builder(
- itemCount: messageExpiryValues.length,
- shrinkWrap: true,
- itemBuilder: (context, i) {
- String key = messageExpiryValues.keys.elementAt(i);
-
- return GestureDetector(
- behavior: HitTestBehavior.opaque,
- onTap: () {
- setState(() {
- selectedExpiry = key;
- });
- },
-
- child: Padding(
- padding: const EdgeInsets.only(left: 30, right: 20, top: 8, bottom: 8),
- child: Row(
- children: [
- selectedExpiry == key ?
- const Icon(Icons.check) :
- const SizedBox(width: 24),
- const SizedBox(width: 16),
- Expanded(
- child: Align(
- alignment: Alignment.centerLeft,
- child: Text(
- messageExpiryValues[key] ?? '',
- style: const TextStyle(
- fontSize: 20,
- fontWeight: FontWeight.normal,
- ),
- ),
- )
- )
- ],
- )
- )
- );
- },
- );
- }
- }
|