working language dialog

This commit is contained in:
ryleedavis 2022-11-02 14:16:38 -06:00
parent 95a35a5dd0
commit 4aec412ce7

View file

@ -12,6 +12,10 @@ import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/stack_text_field.dart'; import 'package:stackwallet/widgets/stack_text_field.dart';
import '../../../../utilities/assets.dart'; import '../../../../utilities/assets.dart';
import '../../../../utilities/theme/stack_colors.dart';
import '../../../../widgets/icon_widgets/x_icon.dart';
import '../../../../widgets/rounded_container.dart';
import '../../../../widgets/textfield_icon_button.dart';
class LanguageDialog extends ConsumerStatefulWidget { class LanguageDialog extends ConsumerStatefulWidget {
const LanguageDialog({Key? key}) : super(key: key); const LanguageDialog({Key? key}) : super(key: key);
@ -94,6 +98,13 @@ class _LanguageDialog extends ConsumerState<LanguageDialog> {
current = ref current = ref
.watch(prefsChangeNotifierProvider.select((value) => value.language)); .watch(prefsChangeNotifierProvider.select((value) => value.language));
listWithoutSelected = languages;
if (current.isNotEmpty) {
listWithoutSelected.remove(current);
listWithoutSelected.insert(0, current);
}
listWithoutSelected = _filtered();
return DesktopDialog( return DesktopDialog(
maxHeight: 700, maxHeight: 700,
maxWidth: 600, maxWidth: 600,
@ -113,41 +124,196 @@ class _LanguageDialog extends ConsumerState<LanguageDialog> {
const DesktopDialogCloseButton(), const DesktopDialogCloseButton(),
], ],
), ),
Padding( Expanded(
padding: EdgeInsets.symmetric(vertical: 16, horizontal: 32), child: NestedScrollView(
child: Column( floatHeaderSlivers: true,
children: [ headerSliverBuilder: (context, innerBoxIsScrolled) {
ClipRRect( return [
borderRadius: BorderRadius.circular( SliverOverlapAbsorber(
Constants.size.circularBorderRadius, handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
), context),
child: TextField( sliver: SliverToBoxAdapter(
autocorrect: false, child: Padding(
enableSuggestions: false, padding:
controller: searchLanguageController, EdgeInsets.symmetric(vertical: 16, horizontal: 32),
focusNode: searchLanguageFocusNode, child: Column(
style: STextStyles.desktopTextMedium(context).copyWith( children: [
height: 2, Padding(
), padding: const EdgeInsets.only(bottom: 16),
textAlign: TextAlign.left, child: ClipRRect(
decoration: standardInputDecoration( borderRadius: BorderRadius.circular(
"Search", searchLanguageFocusNode, context) Constants.size.circularBorderRadius,
.copyWith( ),
prefixIcon: Padding( child: TextField(
padding: const EdgeInsets.symmetric( autocorrect: false,
horizontal: 10, enableSuggestions: false,
vertical: 16, controller: searchLanguageController,
), focusNode: searchLanguageFocusNode,
child: SvgPicture.asset( style: STextStyles.desktopTextMedium(context)
Assets.svg.search, .copyWith(
width: 16, height: 2,
height: 16, ),
textAlign: TextAlign.left,
decoration: standardInputDecoration("Search",
searchLanguageFocusNode, context)
.copyWith(
prefixIcon: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 16,
),
child: SvgPicture.asset(
Assets.svg.search,
width: 16,
height: 16,
),
),
suffixIcon: searchLanguageController
.text.isNotEmpty
? Padding(
padding:
const EdgeInsets.only(right: 0),
child: UnconstrainedBox(
child: Row(
children: [
TextFieldIconButton(
child: const XIcon(),
onTap: () async {
setState(() {
searchLanguageController
.text = "";
filter = "";
});
},
),
],
),
),
)
: null,
),
),
),
),
],
), ),
), ),
), ),
), ),
), ];
], },
body: Builder(
builder: (context) {
return CustomScrollView(
slivers: [
SliverOverlapInjector(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
context,
),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return Container(
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.popupBG,
borderRadius: _borderRadius(index),
),
child: Padding(
padding: const EdgeInsets.all(4),
key: Key(
"desktopSelectLanguage_${listWithoutSelected[index]}"),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 32),
child: RoundedContainer(
padding: const EdgeInsets.all(0),
color: index == 0
? Theme.of(context)
.extension<StackColors>()!
.currencyListItemBG
: Theme.of(context)
.extension<StackColors>()!
.popupBG,
child: RawMaterialButton(
onPressed: () async {
onTap(index);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
SizedBox(
width: 20,
height: 20,
child: Radio(
activeColor: Theme.of(context)
.extension<StackColors>()!
.radioButtonIconEnabled,
value: true,
groupValue: index == 0,
onChanged: (_) {
onTap(index);
},
),
),
const SizedBox(
width: 12,
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
listWithoutSelected[index],
key: (index == 0)
? const Key(
"desktopSettingsSelectedLanguageText")
: null,
style:
STextStyles.largeMedium14(
context),
),
const SizedBox(
height: 2,
),
Text(
listWithoutSelected[index],
key: (index == 0)
? const Key(
"desktopSettingsSelectedLanguageTextDescription")
: null,
style:
STextStyles.itemSubtitle(
context),
),
],
),
],
),
),
),
),
),
),
);
},
childCount: listWithoutSelected.length,
),
),
],
);
},
),
), ),
), ),
const Spacer(), const Spacer(),
@ -180,183 +346,3 @@ class _LanguageDialog extends ConsumerState<LanguageDialog> {
); );
} }
} }
// NestedScrollView(
// floatHeaderSlivers: true,
// headerSliverBuilder: (context, innerBoxIsScrolled) {
// return [
// SliverOverlapAbsorber(
// handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
// context),
// sliver: SliverToBoxAdapter(
// child: Padding(
// padding: const EdgeInsets.only(bottom: 16),
// child: ClipRRect(
// borderRadius: BorderRadius.circular(
// Constants.size.circularBorderRadius,
// ),
// child: TextField(
// autocorrect: Util.isDesktop ? false : true,
// enableSuggestions:
// Util.isDesktop ? false : true,
// controller: searchLanguageController,
// focusNode: searchLanguageFocusNode,
// onChanged: (newString) {
// setState(() => filter = newString);
// },
// style: STextStyles.field(context),
// decoration: standardInputDecoration(
// "Search",
// searchLanguageFocusNode,
// context,
// ).copyWith(
// prefixIcon: Padding(
// padding: const EdgeInsets.symmetric(
// horizontal: 10,
// vertical: 16,
// ),
// child: SvgPicture.asset(
// Assets.svg.search,
// width: 16,
// height: 16,
// ),
// ),
// suffixIcon: searchLanguageController
// .text.isNotEmpty
// ? Padding(
// padding:
// const EdgeInsets.only(right: 0),
// child: UnconstrainedBox(
// child: Row(
// children: [
// TextFieldIconButton(
// child: const XIcon(),
// onTap: () async {
// setState(() {
// searchLanguageController
// .text = "";
// filter = "";
// });
// },
// ),
// ],
// ),
// ),
// )
// : null,
// ),
// ),
// ),
// ),
// ),
// ),
// ];
// },
// body: Builder(
// builder: (context) {
// return CustomScrollView(
// slivers: [
// SliverOverlapInjector(
// handle:
// NestedScrollView.sliverOverlapAbsorberHandleFor(
// context,
// ),
// ),
// SliverList(
// delegate: SliverChildBuilderDelegate(
// (context, index) {
// return Container(
// decoration: BoxDecoration(
// color: Theme.of(context)
// .extension<StackColors>()!
// .popupBG,
// borderRadius: _borderRadius(index),
// ),
// child: Padding(
// padding: const EdgeInsets.all(4),
// key: Key(
// "languageSelect_${listWithoutSelected[index]}"),
// child: RoundedContainer(
// padding: const EdgeInsets.all(0),
// color: index == 0
// ? Theme.of(context)
// .extension<StackColors>()!
// .currencyListItemBG
// : Theme.of(context)
// .extension<StackColors>()!
// .popupBG,
// child: RawMaterialButton(
// onPressed: () async {
// onTap(index);
// },
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(
// Constants.size.circularBorderRadius,
// ),
// ),
// child: Padding(
// padding: const EdgeInsets.all(12.0),
// child: Row(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// children: [
// SizedBox(
// width: 20,
// height: 20,
// child: Radio(
// activeColor: Theme.of(context)
// .extension<StackColors>()!
// .radioButtonIconEnabled,
// value: true,
// groupValue: index == 0,
// onChanged: (_) {
// onTap(index);
// },
// ),
// ),
// const SizedBox(
// width: 12,
// ),
// Column(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// children: [
// Text(
// listWithoutSelected[index],
// key: (index == 0)
// ? const Key(
// "selectedLanguageSettingsLanguageText")
// : null,
// style: STextStyles
// .largeMedium14(context),
// ),
// const SizedBox(
// height: 2,
// ),
// Text(
// listWithoutSelected[index],
// key: (index == 0)
// ? const Key(
// "selectedLanguageSettingsLanguageTextDescription")
// : null,
// style: STextStyles
// .itemSubtitle(context),
// ),
// ],
// ),
// ],
// ),
// ),
// ),
// ),
// ),
// );
// },
// childCount: listWithoutSelected.length,
// ),
// ),
// ],
// );
// },
// ),
// ),