mirror of
https://github.com/Iconica-Development/flutter_profile.git
synced 2025-05-19 01:03:45 +02:00
feat: added prioritizedItems
This commit is contained in:
parent
723d4d0c23
commit
e00c4dcfcc
11 changed files with 61 additions and 70 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -19,7 +19,7 @@ migrate_working_dir/
|
||||||
# The .vscode folder contains launch configuration and tasks you configure in
|
# The .vscode folder contains launch configuration and tasks you configure in
|
||||||
# VS Code which you may wish to be included in version control, so this line
|
# VS Code which you may wish to be included in version control, so this line
|
||||||
# is commented out by default.
|
# is commented out by default.
|
||||||
#.vscode/
|
.vscode/
|
||||||
|
|
||||||
# Flutter/Dart/Pub related
|
# Flutter/Dart/Pub related
|
||||||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
|
||||||
|
@ -28,3 +28,10 @@ migrate_working_dir/
|
||||||
.dart_tool/
|
.dart_tool/
|
||||||
.packages
|
.packages
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
example/android/
|
||||||
|
example/ios/
|
||||||
|
example/linux/
|
||||||
|
example/macos/
|
||||||
|
example/windows/
|
||||||
|
example/web/
|
|
@ -1,3 +1,7 @@
|
||||||
## 0.0.1
|
## 0.0.1
|
||||||
|
|
||||||
* TODO: Describe initial release.
|
* Initial release.
|
||||||
|
|
||||||
|
## 0.0.2
|
||||||
|
|
||||||
|
* Add prioritizedItems option to display items at the top of the page.
|
||||||
|
|
1
LICENSE
1
LICENSE
|
@ -1 +0,0 @@
|
||||||
TODO: Add your license here.
|
|
|
@ -29,6 +29,8 @@ Underneath are all paramters, of the 'ProfilePage' widget, listed with an explan
|
||||||
| showAvatar | The ability to disable/enable the avatar. |
|
| showAvatar | The ability to disable/enable the avatar. |
|
||||||
| itemBuilder | The way to override the standard textfield for each standard piece of user data. |
|
| itemBuilder | The way to override the standard textfield for each standard piece of user data. |
|
||||||
| itemBuilderOptions | The options used by the standard itemBuilder to alter the function and style of the textfields |
|
| itemBuilderOptions | The options used by the standard itemBuilder to alter the function and style of the textfields |
|
||||||
|
| prioritizedItems | The items that are displayed at the top of the page. Before all the other items in the list and the default items |
|
||||||
|
|
||||||
|
|
||||||
## Issues
|
## Issues
|
||||||
|
|
||||||
|
@ -36,8 +38,8 @@ Please file any issues, bugs or feature request as an issue on our [GitHub](http
|
||||||
|
|
||||||
## Want to contribute
|
## Want to contribute
|
||||||
|
|
||||||
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide](../CONTRIBUTING.md) and send us your [pull request](URL TO PULL REQUEST TAB IN REPO).
|
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide](../CONTRIBUTING.md) and send us your [pull request](https://github.com/Iconica-Development/flutter_profile/pulls).
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
|
||||||
This `flutter-image-picker` for Flutter is developed by [Iconica](https://iconica.nl). You can contact us at <support@iconica.nl>
|
This `flutter_profile` for Flutter is developed by [Iconica](https://iconica.nl). You can contact us at <support@iconica.nl>
|
||||||
|
|
2
example/.gitignore
vendored
2
example/.gitignore
vendored
|
@ -19,7 +19,7 @@ migrate_working_dir/
|
||||||
# The .vscode folder contains launch configuration and tasks you configure in
|
# The .vscode folder contains launch configuration and tasks you configure in
|
||||||
# VS Code which you may wish to be included in version control, so this line
|
# VS Code which you may wish to be included in version control, so this line
|
||||||
# is commented out by default.
|
# is commented out by default.
|
||||||
#.vscode/
|
.vscode/
|
||||||
|
|
||||||
# Flutter/Dart/Pub related
|
# Flutter/Dart/Pub related
|
||||||
**/doc/api/
|
**/doc/api/
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
# example
|
|
||||||
|
|
||||||
A new Flutter project.
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
This project is a starting point for a Flutter application.
|
|
||||||
|
|
||||||
A few resources to get you started if this is your first Flutter project:
|
|
||||||
|
|
||||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
|
||||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
|
||||||
|
|
||||||
For help getting started with Flutter development, view the
|
|
||||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
|
||||||
samples, guidance on mobile development, and a full API reference.
|
|
|
@ -68,7 +68,7 @@ packages:
|
||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "0.0.1"
|
version: "0.0.2"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|
|
@ -2,6 +2,7 @@ library flutter_profile;
|
||||||
|
|
||||||
export 'src/widgets/profile/profile_page.dart';
|
export 'src/widgets/profile/profile_page.dart';
|
||||||
export 'src/widgets/profile/profile_style.dart';
|
export 'src/widgets/profile/profile_style.dart';
|
||||||
|
export 'src/widgets/avatar/avatar.dart';
|
||||||
export 'src/widgets/avatar/avatar_style.dart';
|
export 'src/widgets/avatar/avatar_style.dart';
|
||||||
export 'src/services/profile_service.dart';
|
export 'src/services/profile_service.dart';
|
||||||
export 'src/widgets/item_builder/item_builder.dart';
|
export 'src/widgets/item_builder/item_builder.dart';
|
||||||
|
|
|
@ -34,6 +34,7 @@ class ProfilePage extends StatefulWidget {
|
||||||
this.itemBuilder,
|
this.itemBuilder,
|
||||||
this.itemBuilderOptions,
|
this.itemBuilderOptions,
|
||||||
this.bottomActionText,
|
this.bottomActionText,
|
||||||
|
this.prioritizedItems = const [],
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// User containing all the user data.
|
/// User containing all the user data.
|
||||||
|
@ -57,9 +58,12 @@ class ProfilePage extends StatefulWidget {
|
||||||
/// 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;
|
||||||
|
|
||||||
/// Used to set settings of eacht field in user.
|
/// Used to set settings of each field in user.
|
||||||
final ItemBuilderOptions? itemBuilderOptions;
|
final ItemBuilderOptions? itemBuilderOptions;
|
||||||
|
|
||||||
|
/// Map keys of items that should be shown first before the default items and the rest of the items.
|
||||||
|
final List<String> prioritizedItems;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ProfilePage> createState() => _ProfilePageState();
|
State<ProfilePage> createState() => _ProfilePageState();
|
||||||
}
|
}
|
||||||
|
@ -79,7 +83,7 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||||
bottomActionText: widget.bottomActionText,
|
bottomActionText: widget.bottomActionText,
|
||||||
itemBuilder: widget.itemBuilder,
|
itemBuilder: widget.itemBuilder,
|
||||||
itemBuilderOptions: widget.itemBuilderOptions,
|
itemBuilderOptions: widget.itemBuilderOptions,
|
||||||
key: UniqueKey(),
|
prioritizedItems: widget.prioritizedItems,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ class ProfileWrapper extends StatefulWidget {
|
||||||
this.itemBuilder,
|
this.itemBuilder,
|
||||||
this.itemBuilderOptions,
|
this.itemBuilderOptions,
|
||||||
this.bottomActionText,
|
this.bottomActionText,
|
||||||
|
this.prioritizedItems = const [],
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final User user;
|
final User user;
|
||||||
|
@ -31,6 +32,9 @@ class ProfileWrapper extends StatefulWidget {
|
||||||
final Function rebuild;
|
final Function rebuild;
|
||||||
final ItemBuilderOptions? itemBuilderOptions;
|
final ItemBuilderOptions? itemBuilderOptions;
|
||||||
|
|
||||||
|
/// Map keys of items that should be shown first before the default items and the rest of the items.
|
||||||
|
final List<String> prioritizedItems;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ProfileWrapper> createState() => _ProfileWrapperState();
|
State<ProfileWrapper> createState() => _ProfileWrapperState();
|
||||||
}
|
}
|
||||||
|
@ -134,7 +138,7 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
padding: widget.style.pagePadding,
|
padding: widget.style.pagePadding,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
if (widget.showAvatar)
|
if (widget.showAvatar) ...[
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await widget.service.uploadImage(context);
|
await widget.service.uploadImage(context);
|
||||||
|
@ -147,13 +151,14 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
image: widget.user.image,
|
image: widget.user.image,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.showAvatar)
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: widget.style.betweenDefaultItemPadding,
|
height: widget.style.betweenDefaultItemPadding,
|
||||||
),
|
),
|
||||||
...defaultItems,
|
],
|
||||||
|
// all the items that have priority above the default items
|
||||||
ItemList(
|
ItemList(
|
||||||
widget.user.profileData!.toMap(),
|
Map.fromEntries(widget.user.profileData!.toMap().entries.where(
|
||||||
|
(element) => widget.prioritizedItems.contains(element.key))),
|
||||||
widget.user.profileData!.mapWidget(
|
widget.user.profileData!.mapWidget(
|
||||||
() {
|
() {
|
||||||
widget.rebuild();
|
widget.rebuild();
|
||||||
|
@ -167,12 +172,29 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
itemBuilder: widget.itemBuilder,
|
itemBuilder: widget.itemBuilder,
|
||||||
itemBuilderOptions: widget.itemBuilderOptions,
|
itemBuilderOptions: widget.itemBuilderOptions,
|
||||||
),
|
),
|
||||||
if (widget.bottomActionText != null)
|
...defaultItems,
|
||||||
|
// remove all the items that have priority from the widget.user.profileData!.toMap()
|
||||||
|
ItemList(
|
||||||
|
Map.fromEntries(widget.user.profileData!.toMap().entries.where(
|
||||||
|
(element) => !widget.prioritizedItems.contains(element.key))),
|
||||||
|
widget.user.profileData!.mapWidget(
|
||||||
|
() {
|
||||||
|
widget.rebuild();
|
||||||
|
},
|
||||||
|
context,
|
||||||
|
),
|
||||||
|
widget.style.betweenDefaultItemPadding,
|
||||||
|
(key, value) {
|
||||||
|
widget.service.editProfile(widget.user, key, value);
|
||||||
|
},
|
||||||
|
itemBuilder: widget.itemBuilder,
|
||||||
|
itemBuilderOptions: widget.itemBuilderOptions,
|
||||||
|
),
|
||||||
|
if (widget.bottomActionText != null) ...[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: widget.style.betweenDefaultItemPadding,
|
height: widget.style.betweenDefaultItemPadding,
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
if (widget.bottomActionText != null)
|
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
widget.service.pageBottomAction();
|
widget.service.pageBottomAction();
|
||||||
|
@ -182,6 +204,9 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
child: Text(widget.bottomActionText!),
|
child: Text(widget.bottomActionText!),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
] else ...[
|
||||||
|
const Spacer(),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
41
pubspec.yaml
41
pubspec.yaml
|
@ -1,7 +1,7 @@
|
||||||
name: flutter_profile
|
name: flutter_profile
|
||||||
description: A new Flutter package project.
|
description: Flutter profile package
|
||||||
version: 0.0.1
|
version: 0.0.2
|
||||||
homepage:
|
repository: https://github.com/Iconica-Development/flutter_profile
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.6 <3.0.0"
|
sdk: ">=2.17.6 <3.0.0"
|
||||||
|
@ -16,39 +16,4 @@ dev_dependencies:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^2.0.0
|
flutter_lints: ^2.0.0
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
|
||||||
|
|
||||||
# The following section is specific to Flutter packages.
|
|
||||||
flutter:
|
flutter:
|
||||||
|
|
||||||
# To add assets to your package, add an assets section, like this:
|
|
||||||
# assets:
|
|
||||||
# - images/a_dot_burr.jpeg
|
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
#
|
|
||||||
# For details regarding assets in packages, see
|
|
||||||
# https://flutter.dev/assets-and-images/#from-packages
|
|
||||||
#
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
|
||||||
|
|
||||||
# To add custom fonts to your package, add a fonts section here,
|
|
||||||
# in this "flutter" section. Each entry in this list should have a
|
|
||||||
# "family" key with the font family name, and a "fonts" key with a
|
|
||||||
# list giving the asset and other descriptors for the font. For
|
|
||||||
# example:
|
|
||||||
# fonts:
|
|
||||||
# - family: Schyler
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/Schyler-Regular.ttf
|
|
||||||
# - asset: fonts/Schyler-Italic.ttf
|
|
||||||
# style: italic
|
|
||||||
# - family: Trajan Pro
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/TrajanPro.ttf
|
|
||||||
# - asset: fonts/TrajanPro_Bold.ttf
|
|
||||||
# weight: 700
|
|
||||||
#
|
|
||||||
# For details regarding fonts in packages, see
|
|
||||||
# https://flutter.dev/custom-fonts/#from-packages
|
|
||||||
|
|
Loading…
Reference in a new issue