mod: 默认使用web端推荐
This commit is contained in:
@ -1,18 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pilipala/models/common/theme_type.dart';
|
||||
|
||||
class SelectDialog<T> extends StatefulWidget {
|
||||
final T value;
|
||||
final String title;
|
||||
final List<dynamic> values;
|
||||
const SelectDialog({super.key, required this.value, required this.values, required this.title});
|
||||
const SelectDialog(
|
||||
{super.key,
|
||||
required this.value,
|
||||
required this.values,
|
||||
required this.title});
|
||||
|
||||
@override
|
||||
_SelectDialogState<T> createState() => _SelectDialogState<T>();
|
||||
}
|
||||
|
||||
class _SelectDialogState<T> extends State<SelectDialog<T>> {
|
||||
|
||||
late T _tempValue;
|
||||
|
||||
@override
|
||||
@ -28,40 +30,39 @@ class _SelectDialogState<T> extends State<SelectDialog<T>> {
|
||||
return AlertDialog(
|
||||
title: Text(widget.title),
|
||||
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
|
||||
content: StatefulBuilder(
|
||||
builder: (context, StateSetter setState) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (var i in widget.values) ...[
|
||||
RadioListTile(
|
||||
value: i['value'],
|
||||
title: Text(i['title'], style: titleStyle),
|
||||
groupValue: _tempValue,
|
||||
onChanged: (value) {
|
||||
print(value);
|
||||
setState(() {
|
||||
_tempValue = value as T;
|
||||
});
|
||||
},
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
content: StatefulBuilder(builder: (context, StateSetter setState) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (var i in widget.values) ...[
|
||||
RadioListTile(
|
||||
value: i['value'],
|
||||
title: Text(i['title'], style: titleStyle),
|
||||
groupValue: _tempValue,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_tempValue = value as T;
|
||||
});
|
||||
},
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
)),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, _tempValue),
|
||||
child: const Text('确定'))
|
||||
onPressed: () => Navigator.pop(context, _tempValue),
|
||||
child: const Text('确定'),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user