diff --git a/.gitignore b/.gitignore index 96486fd..b77f4ca 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ migrate_working_dir/ # 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 # is commented out by default. -#.vscode/ +.vscode/ # Flutter/Dart/Pub related # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. @@ -28,3 +28,10 @@ migrate_working_dir/ .dart_tool/ .packages build/ + +example/android/ +example/ios/ +example/linux/ +example/macos/ +example/windows/ +example/web/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cc7d8..9c75b98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ ## 0.0.1 -* TODO: Describe initial release. +* Initial release. + +## 0.0.2 + +* Add prioritizedItems option to display items at the top of the page. diff --git a/LICENSE b/LICENSE deleted file mode 100644 index ba75c69..0000000 --- a/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/README.md b/README.md index d04c45d..8c4eba0 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Underneath are all paramters, of the 'ProfilePage' widget, listed with an explan | showAvatar | The ability to disable/enable the avatar. | | 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 | +| 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 @@ -36,8 +38,8 @@ Please file any issues, bugs or feature request as an issue on our [GitHub](http ## 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 -This `flutter-image-picker` for Flutter is developed by [Iconica](https://iconica.nl). You can contact us at +This `flutter_profile` for Flutter is developed by [Iconica](https://iconica.nl). You can contact us at diff --git a/example/.gitignore b/example/.gitignore index a8e938c..79cf399 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -19,7 +19,7 @@ migrate_working_dir/ # 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 # is commented out by default. -#.vscode/ +.vscode/ # Flutter/Dart/Pub related **/doc/api/ diff --git a/example/README.md b/example/README.md index 2b3fce4..e69de29 100644 --- a/example/README.md +++ b/example/README.md @@ -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. diff --git a/example/pubspec.lock b/example/pubspec.lock index e78ef51..9a64588 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -68,7 +68,7 @@ packages: path: ".." relative: true source: path - version: "0.0.1" + version: "0.0.2" flutter_test: dependency: "direct dev" description: flutter diff --git a/lib/flutter_profile.dart b/lib/flutter_profile.dart index 37389fc..19a1dac 100644 --- a/lib/flutter_profile.dart +++ b/lib/flutter_profile.dart @@ -2,6 +2,7 @@ library flutter_profile; export 'src/widgets/profile/profile_page.dart'; export 'src/widgets/profile/profile_style.dart'; +export 'src/widgets/avatar/avatar.dart'; export 'src/widgets/avatar/avatar_style.dart'; export 'src/services/profile_service.dart'; export 'src/widgets/item_builder/item_builder.dart'; diff --git a/lib/src/widgets/profile/profile_page.dart b/lib/src/widgets/profile/profile_page.dart index aae0db7..5cff392 100644 --- a/lib/src/widgets/profile/profile_page.dart +++ b/lib/src/widgets/profile/profile_page.dart @@ -34,6 +34,7 @@ class ProfilePage extends StatefulWidget { this.itemBuilder, this.itemBuilderOptions, this.bottomActionText, + this.prioritizedItems = const [], }) : super(key: key); /// User containing all the user data. @@ -57,9 +58,12 @@ class ProfilePage extends StatefulWidget { /// Itembuilder is used the build each field in the user. final ItemBuilder? itemBuilder; - /// Used to set settings of eacht field in user. + /// Used to set settings of each field in user. final ItemBuilderOptions? itemBuilderOptions; + /// Map keys of items that should be shown first before the default items and the rest of the items. + final List prioritizedItems; + @override State createState() => _ProfilePageState(); } @@ -79,7 +83,7 @@ class _ProfilePageState extends State { bottomActionText: widget.bottomActionText, itemBuilder: widget.itemBuilder, itemBuilderOptions: widget.itemBuilderOptions, - key: UniqueKey(), + prioritizedItems: widget.prioritizedItems, ); } } diff --git a/lib/src/widgets/profile/proifle_wrapper.dart b/lib/src/widgets/profile/proifle_wrapper.dart index 47fc184..bd6221b 100644 --- a/lib/src/widgets/profile/proifle_wrapper.dart +++ b/lib/src/widgets/profile/proifle_wrapper.dart @@ -19,6 +19,7 @@ class ProfileWrapper extends StatefulWidget { this.itemBuilder, this.itemBuilderOptions, this.bottomActionText, + this.prioritizedItems = const [], }) : super(key: key); final User user; @@ -31,6 +32,9 @@ class ProfileWrapper extends StatefulWidget { final Function rebuild; final ItemBuilderOptions? itemBuilderOptions; + /// Map keys of items that should be shown first before the default items and the rest of the items. + final List prioritizedItems; + @override State createState() => _ProfileWrapperState(); } @@ -134,7 +138,7 @@ class _ProfileWrapperState extends State { padding: widget.style.pagePadding, child: Column( children: [ - if (widget.showAvatar) + if (widget.showAvatar) ...[ InkWell( onTap: () async { await widget.service.uploadImage(context); @@ -147,13 +151,14 @@ class _ProfileWrapperState extends State { image: widget.user.image, ), ), - if (widget.showAvatar) SizedBox( height: widget.style.betweenDefaultItemPadding, ), - ...defaultItems, + ], + // all the items that have priority above the default items ItemList( - widget.user.profileData!.toMap(), + Map.fromEntries(widget.user.profileData!.toMap().entries.where( + (element) => widget.prioritizedItems.contains(element.key))), widget.user.profileData!.mapWidget( () { widget.rebuild(); @@ -167,12 +172,29 @@ class _ProfileWrapperState extends State { itemBuilder: widget.itemBuilder, 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( height: widget.style.betweenDefaultItemPadding, ), - const Spacer(), - if (widget.bottomActionText != null) + const Spacer(), InkWell( onTap: () { widget.service.pageBottomAction(); @@ -182,6 +204,9 @@ class _ProfileWrapperState extends State { child: Text(widget.bottomActionText!), ), ), + ] else ...[ + const Spacer(), + ], ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index e425458..9004e6a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_profile -description: A new Flutter package project. -version: 0.0.1 -homepage: +description: Flutter profile package +version: 0.0.2 +repository: https://github.com/Iconica-Development/flutter_profile environment: sdk: ">=2.17.6 <3.0.0" @@ -16,39 +16,4 @@ dev_dependencies: sdk: flutter 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: - - # 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