Made the delete profile text interchangeable

When the text is set to null the feature is disabled
This commit is contained in:
Jacques Doeleman 2022-09-21 10:01:48 +02:00
parent d0c027820a
commit d4e43ef41c
2 changed files with 10 additions and 10 deletions

View file

@ -14,7 +14,7 @@ import 'package:profile/src/widgets/profile/proifle_wrapper.dart';
/// ///
/// ShowAvatar can be set using a [bool] to determine whether the avatar should be shown and be able to be set by the user. Default set to true. /// ShowAvatar can be set using a [bool] to determine whether the avatar should be shown and be able to be set by the user. Default set to true.
/// ///
/// ShowDeleteProfile can be set using a [bool] set determine whether te user can delete the profile. Default set to true. /// DeleteProfileText sets the text for the inkwell at the bottom of the page. If this is set the null then the deletion of the profile is disabled.
/// ///
/// ItemBuilder is used to determine how the user data is represented. /// ItemBuilder is used to determine how the user data is represented.
/// ///
@ -29,7 +29,7 @@ class ProfilePage extends StatefulWidget {
this.showAvatar = true, this.showAvatar = true,
this.itemBuilder, this.itemBuilder,
this.itemBuilderOptions, this.itemBuilderOptions,
this.showDeleteProfile = true, this.deleteProfileText = 'Delete proifle',
}) : super(key: key); }) : super(key: key);
/// User containing all the user data. /// User containing all the user data.
@ -47,8 +47,8 @@ class ProfilePage extends StatefulWidget {
/// Whether to show the users avatar. /// Whether to show the users avatar.
final bool showAvatar; final bool showAvatar;
/// Whether to give the user the option to delete their own profile. /// Sets the text for the [InkWell] at the bottom of the profile page. If null deleting the profile is disabled.
final bool showDeleteProfile; final String? deleteProfileText;
/// Itembuilder is used the build each field in the user. /// Itembuilder is used the build each field in the user.
final ItemBuilder? itemBuilder; final ItemBuilder? itemBuilder;
@ -72,7 +72,7 @@ class _ProfilePageState extends State<ProfilePage> {
style: widget.style, style: widget.style,
customAvatar: widget.customAvatar, customAvatar: widget.customAvatar,
showAvatar: widget.showAvatar, showAvatar: widget.showAvatar,
showDeleteProfile: widget.showDeleteProfile, deleteProfileText: widget.deleteProfileText,
itemBuilder: widget.itemBuilder, itemBuilder: widget.itemBuilder,
itemBuilderOptions: widget.itemBuilderOptions, itemBuilderOptions: widget.itemBuilderOptions,
key: UniqueKey(), key: UniqueKey(),

View file

@ -17,7 +17,7 @@ class ProfileWrapper extends StatefulWidget {
this.showAvatar = true, this.showAvatar = true,
this.itemBuilder, this.itemBuilder,
this.itemBuilderOptions, this.itemBuilderOptions,
this.showDeleteProfile = true, this.deleteProfileText = 'Delete proifle',
}) : super(key: key); }) : super(key: key);
final User user; final User user;
@ -25,7 +25,7 @@ class ProfileWrapper extends StatefulWidget {
final ProfileStyle style; final ProfileStyle style;
final Widget? customAvatar; final Widget? customAvatar;
final bool showAvatar; final bool showAvatar;
final bool showDeleteProfile; final String? deleteProfileText;
final ItemBuilder? itemBuilder; final ItemBuilder? itemBuilder;
final Function rebuild; final Function rebuild;
final ItemBuilderOptions? itemBuilderOptions; final ItemBuilderOptions? itemBuilderOptions;
@ -124,17 +124,17 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
itemBuilder: widget.itemBuilder, itemBuilder: widget.itemBuilder,
itemBuilderOptions: widget.itemBuilderOptions, itemBuilderOptions: widget.itemBuilderOptions,
), ),
if (widget.showDeleteProfile) if (widget.deleteProfileText != null)
SizedBox( SizedBox(
height: widget.style.betweenDefaultItemPadding, height: widget.style.betweenDefaultItemPadding,
), ),
const Spacer(), const Spacer(),
if (widget.showDeleteProfile) if (widget.deleteProfileText != null)
InkWell( InkWell(
onTap: () { onTap: () {
widget.service.deleteProfile(); widget.service.deleteProfile();
}, },
child: const Text('Profiel verwijderen'), child: Text(widget.deleteProfileText!),
), ),
], ],
), ),