Skip to content

Commit

Permalink
Use global onboarding flag to customize profile info content [#4612].
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihail Varbanov committed Jan 17, 2025
1 parent bbf4f39 commit b44d8d8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/ui/onboarding2/Onboarding2ProfileInfoPanel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class _Onboarding2ProfileInfoPanelState extends State<Onboarding2ProfileInfoPane
ProfileInfoPage(key: _profileInfoKey,
contentType: ProfileInfo.directoryInfo,
onStateChanged: _onProfileStateChanged,
showProfileCommands: false,
onboarding: true,
),
);

Expand Down
8 changes: 5 additions & 3 deletions lib/ui/profile/ProfileInfoEditPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class ProfileInfoEditPage extends StatefulWidget {
final Uint8List? pronunciationAudioData;
final Uint8List? photoImageData;
final String? photoImageToken;
final bool showProfileCommands;
final bool onboarding;
final void Function({Auth2UserProfile? profile, Auth2UserPrivacy? privacy, Uint8List? pronunciationAudioData, Uint8List? photoImageData, String? photoImageToken})? onFinishEdit;

ProfileInfoEditPage({super.key, required this.contentType,
this.profile, this.privacy,
this.pronunciationAudioData, this.photoImageData, this.photoImageToken,
this.showProfileCommands = true, this.onFinishEdit
this.onboarding = false, this.onFinishEdit
});

@override
Expand All @@ -61,6 +61,8 @@ class ProfileInfoEditPageState extends ProfileDirectoryMyInfoBasePageState<Profi
double _screenInsetsBottom = 0;
Timer? _onScreenInsetsBottomChangedTimer;

bool get _showProfileCommands => (widget.onboarding == false);

@override
void initState() {
WidgetsBinding.instance.addObserver(this);
Expand Down Expand Up @@ -136,7 +138,7 @@ class ProfileInfoEditPageState extends ProfileDirectoryMyInfoBasePageState<Profi
_phoneSection,
_websiteSection,

if (widget.showProfileCommands)
if (_showProfileCommands)
Padding(padding: EdgeInsets.only(top: 24, bottom: 16), child:
_commandBar,
),
Expand Down
16 changes: 9 additions & 7 deletions lib/ui/profile/ProfileInfoPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ class ProfileInfoPage extends StatefulWidget {

final ProfileInfo contentType;
final Map<String, dynamic>? params;
final bool showProfileCommands;
final bool showAccountCommands;
final bool onboarding;
final void Function()? onStateChanged;

ProfileInfoPage({super.key, required this.contentType, this.params, this.showProfileCommands = true, this.showAccountCommands = false, this.onStateChanged});
ProfileInfoPage({super.key, required this.contentType, this.params, this.onboarding = false, this.onStateChanged});

@override
State<StatefulWidget> createState() => ProfileInfoPageState();
Expand All @@ -62,6 +61,9 @@ class ProfileInfoPageState extends ProfileDirectoryMyInfoBasePageState<ProfileIn
bool _updatingDirectoryVisibility = false;
bool _preparingDeleteAccount = false;

bool get _showProfileCommands => (widget.onboarding == false);
bool get _showAccountCommands => (widget.onboarding == false);

bool get isEditing => _editing;
bool get isLoading => _loading;
bool get directoryVisibility => (_privacy?.public == true);
Expand Down Expand Up @@ -122,7 +124,7 @@ class ProfileInfoPageState extends ProfileDirectoryMyInfoBasePageState<ProfileIn
_editing ? _editContent : _previewContent,
]),

if (widget.showAccountCommands && !_editing)
if (_showAccountCommands && !_editing)
_accountCommands,
],);
}
Expand All @@ -140,7 +142,7 @@ class ProfileInfoPageState extends ProfileDirectoryMyInfoBasePageState<ProfileIn
photoImageData: _photoImageData,
photoImageToken: _photoImageToken,
),
if (widget.showProfileCommands)
if (_showProfileCommands)
Padding(padding: EdgeInsets.only(top: 24), child:
_previewCommandBar,
),
Expand All @@ -156,7 +158,7 @@ class ProfileInfoPageState extends ProfileDirectoryMyInfoBasePageState<ProfileIn
pronunciationAudioData: _pronunciationAudioData,
photoImageData: _photoImageData,
photoImageToken: _photoImageToken,
showProfileCommands: widget.showProfileCommands,
onboarding: widget.onboarding,
onFinishEdit: _onFinishEditInfo,
);

Expand Down Expand Up @@ -509,7 +511,7 @@ class ProfileInfoPageState extends ProfileDirectoryMyInfoBasePageState<ProfileIn
_pronunciationAudioData = pronunciationAudioData;
}

if (widget.showProfileCommands) {
if (_showProfileCommands) {
_editing = false;
}
widget.onStateChanged?.call();
Expand Down
5 changes: 4 additions & 1 deletion lib/ui/profile/ProfileInfoWrapperPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ class _ProfileInfoWrapperPageState extends State<ProfileInfoWrapperPage> impleme
Widget get _myInfoTabPage =>
Padding(padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), child:
Column(children: [
ProfileInfoPage(contentType: ProfileInfo.directoryInfo, params: widget.params, showAccountCommands: true,)
ProfileInfoPage(
contentType: ProfileInfo.directoryInfo,
params: widget.params,
)
],),
);

Expand Down

0 comments on commit b44d8d8

Please sign in to comment.