Skip to content

Commit

Permalink
feat: align edit and create profile
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoenig134 committed Jan 27, 2025
1 parent 7b00097 commit 32542a6
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 91 deletions.
10 changes: 8 additions & 2 deletions apps/enmeshed/lib/profiles/profile/modals/edit_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class _EditProfileState extends State<_EditProfile> {
padding: EdgeInsets.only(bottom: max(MediaQuery.viewInsetsOf(context).bottom, MediaQuery.viewPaddingOf(context).bottom)),
child: Column(
mainAxisSize: MainAxisSize.min,
spacing: 8,
children: [
Padding(
padding: const EdgeInsets.only(top: 8, left: 24, right: 8, bottom: 8),
Expand All @@ -97,6 +98,7 @@ class _EditProfileState extends State<_EditProfile> {
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
Expand All @@ -109,6 +111,11 @@ class _EditProfileState extends State<_EditProfile> {
),
),
Gaps.h32,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(context.l10n.mandatoryField, style: Theme.of(context).textTheme.bodyMedium),
),
Gaps.h24,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextField(
Expand All @@ -117,11 +124,11 @@ class _EditProfileState extends State<_EditProfile> {
textCapitalization: TextCapitalization.sentences,
scrollPadding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
decoration: InputDecoration(
labelText: '${context.l10n.profile_name}*',
suffixIcon: IconButton(
onPressed: _controller.clear,
icon: const Icon(Icons.cancel_outlined),
),
labelText: context.l10n.profile_name,
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(Radius.circular(8)),
borderSide: BorderSide(color: Theme.of(context).colorScheme.outline),
Expand All @@ -133,7 +140,6 @@ class _EditProfileState extends State<_EditProfile> {
),
),
),
Gaps.h24,
],
),
),
Expand Down
177 changes: 88 additions & 89 deletions apps/enmeshed/lib/profiles/profile/widgets/create_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class _CreateProfileState extends State<CreateProfile> {
bool _loading = false;

final _controller = TextEditingController();
final _focusNode = FocusNode();

Uint8List? _newProfilePicture;

Expand All @@ -37,117 +36,117 @@ class _CreateProfileState extends State<CreateProfile> {
super.initState();

_controller.addListener(() => setState(() {}));
_focusNode.requestFocus();
}

@override
void dispose() {
_controller.dispose();
_focusNode.dispose();

super.dispose();
}

@override
Widget build(BuildContext context) {
return ConstrainedBox(
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.9),
child: Stack(
children: [
Scrollbar(
child: Padding(
return PopScope(
canPop: !_loading,
child: ConstrainedBox(
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height * 0.9),
child: Stack(
children: [
Padding(
padding: EdgeInsets.only(bottom: max(MediaQuery.viewInsetsOf(context).bottom, MediaQuery.viewPaddingOf(context).bottom)),
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
Padding(
padding: EdgeInsets.only(top: 8, left: widget.onBackPressed != null ? 8 : 24, right: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (widget.onBackPressed != null) IconButton(icon: Icon(context.adaptiveBackIcon), onPressed: widget.onBackPressed),
Text(context.l10n.profiles_createNew, style: Theme.of(context).textTheme.titleLarge),
IconButton(onPressed: _loading && !_confirmEnabled ? null : () => context.pop(), icon: const Icon(Icons.close)),
],
),
),
Gaps.h16,
if (widget.description != null) ...[
Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 24),
child: Text(widget.description!),
),
Gaps.h20,
],
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: ChangeProfilePicture(
profileName: _controller.text,
onProfilePictureDeleted: () => _newProfilePicture = null,
onProfilePictureChanged: (Uint8List byteData) => _newProfilePicture = byteData,
setProfilePictureLoading: ({required bool loading}) => setState(() => _profilePictureLoading = loading),
),
),
Gaps.h32,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(context.l10n.mandatoryField, style: Theme.of(context).textTheme.bodyMedium),
child: Column(
mainAxisSize: MainAxisSize.min,
spacing: 8,
children: [
Padding(
padding: EdgeInsets.only(top: 8, left: widget.onBackPressed != null ? 8 : 24, right: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (widget.onBackPressed != null) IconButton(icon: Icon(context.adaptiveBackIcon), onPressed: widget.onBackPressed),
Text(context.l10n.profiles_createNew, style: Theme.of(context).textTheme.titleLarge),
IconButton(onPressed: _loading && !_confirmEnabled ? null : () => context.pop(), icon: const Icon(Icons.close)),
],
),
Gaps.h24,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextField(
focusNode: _focusNode,
maxLength: MaxLength.profileName,
controller: _controller,
textCapitalization: TextCapitalization.sentences,
scrollPadding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
decoration: InputDecoration(
labelText: '${context.l10n.profile_name}*',
suffixIcon: IconButton(
onPressed: _controller.clear,
icon: const Icon(Icons.cancel_outlined),
),
border: OutlineInputBorder(
borderSide: BorderSide(color: Theme.of(context).colorScheme.outline),
borderRadius: const BorderRadius.all(
Radius.circular(8),
),
Flexible(
child: Scrollbar(
child: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.description != null) ...[
Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 24),
child: Text(widget.description!),
),
Gaps.h20,
],
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: ChangeProfilePicture(
profileName: _controller.text,
onProfilePictureDeleted: () => _newProfilePicture = null,
onProfilePictureChanged: (Uint8List byteData) => _newProfilePicture = byteData,
setProfilePictureLoading: ({required bool loading}) => setState(() => _profilePictureLoading = loading),
),
),
Gaps.h32,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: Text(context.l10n.mandatoryField, style: Theme.of(context).textTheme.bodyMedium),
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary),
borderRadius: const BorderRadius.all(
Radius.circular(8),
Gaps.h24,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: TextField(
controller: _controller,
maxLength: MaxLength.profileName,
textCapitalization: TextCapitalization.sentences,
scrollPadding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
decoration: InputDecoration(
labelText: '${context.l10n.profile_name}*',
suffixIcon: IconButton(
onPressed: _controller.clear,
icon: const Icon(Icons.cancel_outlined),
),
border: OutlineInputBorder(
borderRadius: const BorderRadius.all(Radius.circular(8)),
borderSide: BorderSide(color: Theme.of(context).colorScheme.outline),
),
focusedBorder: OutlineInputBorder(
borderRadius: const BorderRadius.all(Radius.circular(8)),
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary),
),
),
),
),
),
],
),
onSubmitted: (_) => _confirmEnabled ? _confirm() : _focusNode.requestFocus(),
),
),
Gaps.h8,
Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 24),
child: Align(
alignment: Alignment.centerRight,
child: FilledButton(
onPressed: _confirmEnabled ? _confirm : null,
style: OutlinedButton.styleFrom(
minimumSize: const Size(100, 36),
),
child: Text(context.l10n.profile_create),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 24),
child: Align(
alignment: Alignment.centerRight,
child: FilledButton(
onPressed: _confirmEnabled ? _confirm : null,
style: OutlinedButton.styleFrom(
minimumSize: const Size(100, 36),
),
child: Text(context.l10n.profile_create),
),
),
],
),
),
],
),
),
),
if (_loading) ModalLoadingOverlay(text: context.l10n.profile_create_inProgress, isDialog: widget.isInDialog),
],
if (_loading) ModalLoadingOverlay(text: context.l10n.profile_create_inProgress, isDialog: widget.isInDialog),
],
),
),
);
}
Expand Down

0 comments on commit 32542a6

Please sign in to comment.