mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
wip: new contact emoji selection and crypto selection
This commit is contained in:
parent
9df0569bb1
commit
9417d78c81
1 changed files with 501 additions and 357 deletions
|
@ -15,15 +15,17 @@ import 'package:stackwallet/utilities/clipboard_interface.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
|
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
||||||
import 'package:stackwallet/widgets/emoji_select_sheet.dart';
|
import 'package:stackwallet/widgets/emoji_select_sheet.dart';
|
||||||
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
|
||||||
import 'package:stackwallet/widgets/stack_text_field.dart';
|
import 'package:stackwallet/widgets/stack_text_field.dart';
|
||||||
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
import 'package:stackwallet/widgets/textfield_icon_button.dart';
|
||||||
|
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
|
||||||
|
|
||||||
class AddAddressBookEntryView extends ConsumerStatefulWidget {
|
class AddAddressBookEntryView extends ConsumerStatefulWidget {
|
||||||
const AddAddressBookEntryView({
|
const AddAddressBookEntryView({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -108,14 +110,20 @@ class _AddAddressBookEntryViewState
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
debugPrint("BUILD: $runtimeType");
|
debugPrint("BUILD: $runtimeType");
|
||||||
|
|
||||||
|
final isDesktop = Util.isDesktop;
|
||||||
|
return ConditionalParent(
|
||||||
|
condition: !isDesktop,
|
||||||
|
builder: (child) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
backgroundColor:
|
||||||
|
Theme.of(context).extension<StackColors>()!.background,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: AppBarBackButton(
|
leading: AppBarBackButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (FocusScope.of(context).hasFocus) {
|
if (FocusScope.of(context).hasFocus) {
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 75));
|
await Future<void>.delayed(
|
||||||
|
const Duration(milliseconds: 75));
|
||||||
}
|
}
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
@ -139,7 +147,9 @@ class _AddAddressBookEntryViewState
|
||||||
key: const Key("addAddressBookEntryFavoriteButtonKey"),
|
key: const Key("addAddressBookEntryFavoriteButtonKey"),
|
||||||
size: 36,
|
size: 36,
|
||||||
shadows: const [],
|
shadows: const [],
|
||||||
color: Theme.of(context).extension<StackColors>()!.background,
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.background,
|
||||||
icon: SvgPicture.asset(
|
icon: SvgPicture.asset(
|
||||||
Assets.svg.star,
|
Assets.svg.star,
|
||||||
color: _isFavorite
|
color: _isFavorite
|
||||||
|
@ -162,7 +172,63 @@ class _AddAddressBookEntryViewState
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: LayoutBuilder(
|
body: child);
|
||||||
|
},
|
||||||
|
child: ConditionalParent(
|
||||||
|
condition: isDesktop,
|
||||||
|
builder: (child) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(32),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"New contact",
|
||||||
|
style: STextStyles.desktopH3(context),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
AppBarIconButton(
|
||||||
|
key:
|
||||||
|
const Key("addAddressBookEntryFavoriteButtonKey"),
|
||||||
|
size: 36,
|
||||||
|
shadows: const [],
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.background,
|
||||||
|
icon: SvgPicture.asset(
|
||||||
|
Assets.svg.star,
|
||||||
|
color: _isFavorite
|
||||||
|
? Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.favoriteStarActive
|
||||||
|
: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.favoriteStarInactive,
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_isFavorite = !_isFavorite;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const DesktopDialogCloseButton(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Expanded(child: child),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: LayoutBuilder(
|
||||||
builder: (context, constraint) {
|
builder: (context, constraint) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
@ -193,7 +259,10 @@ class _AddAddressBookEntryViewState
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showModalBottomSheet<dynamic>(
|
|
||||||
|
///TODO if desktop make dialog
|
||||||
|
!isDesktop
|
||||||
|
? showModalBottomSheet<dynamic>(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
context: context,
|
context: context,
|
||||||
shape: const RoundedRectangleBorder(
|
shape: const RoundedRectangleBorder(
|
||||||
|
@ -208,6 +277,73 @@ class _AddAddressBookEntryViewState
|
||||||
_selectedEmoji = value;
|
_selectedEmoji = value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
: showDialog<dynamic>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return DesktopDialog(
|
||||||
|
maxHeight: 700,
|
||||||
|
maxWidth: 700,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.all(32),
|
||||||
|
child: Text(
|
||||||
|
"Select emoji",
|
||||||
|
style:
|
||||||
|
STextStyles.desktopH3(
|
||||||
|
context),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder:
|
||||||
|
(context, constraints) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
scrollDirection:
|
||||||
|
Axis.vertical,
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints:
|
||||||
|
BoxConstraints(
|
||||||
|
minHeight: constraints
|
||||||
|
.maxHeight,
|
||||||
|
minWidth: constraints
|
||||||
|
.maxWidth,
|
||||||
|
),
|
||||||
|
child: IntrinsicHeight(
|
||||||
|
child: Column(
|
||||||
|
children: const [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets
|
||||||
|
.symmetric(
|
||||||
|
horizontal:
|
||||||
|
32),
|
||||||
|
// child:
|
||||||
|
// EmojiSelectSheet(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).then((value) {
|
||||||
|
if (value is Emoji) {
|
||||||
|
setState(() {
|
||||||
|
_selectedEmoji = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
@ -233,8 +369,8 @@ class _AddAddressBookEntryViewState
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
_selectedEmoji!.char,
|
_selectedEmoji!.char,
|
||||||
style:
|
style: STextStyles.pageTitleH1(
|
||||||
STextStyles.pageTitleH1(context),
|
context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -316,7 +452,8 @@ class _AddAddressBookEntryViewState
|
||||||
),
|
),
|
||||||
onChanged: (newValue) {
|
onChanged: (newValue) {
|
||||||
ref
|
ref
|
||||||
.read(contactNameIsNotEmptyStateProvider.state)
|
.read(
|
||||||
|
contactNameIsNotEmptyStateProvider.state)
|
||||||
.state = newValue.isNotEmpty;
|
.state = newValue.isNotEmpty;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -430,17 +567,20 @@ class _AddAddressBookEntryViewState
|
||||||
style: shouldEnableSave
|
style: shouldEnableSave
|
||||||
? Theme.of(context)
|
? Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.getPrimaryEnabledButtonColor(context)
|
.getPrimaryEnabledButtonColor(
|
||||||
|
context)
|
||||||
: Theme.of(context)
|
: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.getPrimaryDisabledButtonColor(
|
.getPrimaryDisabledButtonColor(
|
||||||
context),
|
context),
|
||||||
onPressed: shouldEnableSave
|
onPressed: shouldEnableSave
|
||||||
? () async {
|
? () async {
|
||||||
if (FocusScope.of(context).hasFocus) {
|
if (FocusScope.of(context)
|
||||||
|
.hasFocus) {
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
await Future<void>.delayed(
|
await Future<void>.delayed(
|
||||||
const Duration(milliseconds: 75),
|
const Duration(
|
||||||
|
milliseconds: 75),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
List<ContactAddressEntry> entries =
|
List<ContactAddressEntry> entries =
|
||||||
|
@ -449,7 +589,8 @@ class _AddAddressBookEntryViewState
|
||||||
i < forms.length;
|
i < forms.length;
|
||||||
i++) {
|
i++) {
|
||||||
entries.add(ref
|
entries.add(ref
|
||||||
.read(addressEntryDataProvider(
|
.read(
|
||||||
|
addressEntryDataProvider(
|
||||||
forms[i].id))
|
forms[i].id))
|
||||||
.buildAddressEntry());
|
.buildAddressEntry());
|
||||||
}
|
}
|
||||||
|
@ -461,7 +602,8 @@ class _AddAddressBookEntryViewState
|
||||||
);
|
);
|
||||||
|
|
||||||
if (await ref
|
if (await ref
|
||||||
.read(addressBookServiceProvider)
|
.read(
|
||||||
|
addressBookServiceProvider)
|
||||||
.addContact(contact)) {
|
.addContact(contact)) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
@ -474,7 +616,8 @@ class _AddAddressBookEntryViewState
|
||||||
: null,
|
: null,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Save",
|
"Save",
|
||||||
style: STextStyles.button(context).copyWith(
|
style:
|
||||||
|
STextStyles.button(context).copyWith(
|
||||||
color: shouldEnableSave
|
color: shouldEnableSave
|
||||||
? Theme.of(context)
|
? Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
|
@ -498,6 +641,7 @@ class _AddAddressBookEntryViewState
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue