From c235fcdecd1b0d4de931e530dc8968e4a6f029cd Mon Sep 17 00:00:00 2001 From: dab246 Date: Tue, 27 Jul 2021 12:51:15 +0700 Subject: [PATCH] Init model module --- model/.gitignore | 124 ++++++++++++++++++++ model/.metadata | 10 ++ model/README.md | 11 ++ model/lib/account/password.dart | 10 ++ model/lib/account/user_name.dart | 10 ++ model/lib/mailbox/expand_mode.dart | 1 + model/lib/mailbox/presentation_mailbox.dart | 63 ++++++++++ model/lib/mailbox/select_mode.dart | 1 + model/lib/model.dart | 13 ++ model/lib/user/user.dart | 22 ++++ model/lib/user/user_id.dart | 10 ++ model/pubspec.yaml | 99 ++++++++++++++++ 12 files changed, 374 insertions(+) create mode 100644 model/.gitignore create mode 100644 model/.metadata create mode 100644 model/README.md create mode 100644 model/lib/account/password.dart create mode 100644 model/lib/account/user_name.dart create mode 100644 model/lib/mailbox/expand_mode.dart create mode 100644 model/lib/mailbox/presentation_mailbox.dart create mode 100644 model/lib/mailbox/select_mode.dart create mode 100644 model/lib/model.dart create mode 100644 model/lib/user/user.dart create mode 100644 model/lib/user/user_id.dart create mode 100644 model/pubspec.yaml diff --git a/model/.gitignore b/model/.gitignore new file mode 100644 index 000000000..657ee1109 --- /dev/null +++ b/model/.gitignore @@ -0,0 +1,124 @@ +# Miscellaneous +*.class +*.lock +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# Visual Studio Code related +.classpath +.project +.settings/ +.vscode/ + +# Flutter repo-specific +/bin/cache/ +/bin/mingit/ +/dev/benchmarks/mega_gallery/ +/dev/bots/.recipe_deps +/dev/bots/android_tools/ +/dev/devicelab/ABresults*.json +/dev/docs/doc/ +/dev/docs/flutter.docs.zip +/dev/docs/lib/ +/dev/docs/pubspec.yaml +/dev/integration_tests/**/xcuserdata +/dev/integration_tests/**/Pods +/packages/flutter/coverage/ +version +analysis_benchmark.json + +# packages file containing multi-root paths +.packages.generated + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +**/generated_plugin_registrant.dart +.packages +.pub-cache/ +.pub/ +build/ +flutter_*.png +linked_*.ds +unlinked.ds +unlinked_spec.ds + +# Android related +**/android/.gradle +**/android/captures/ +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java +**/android/key.properties +*.jks + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/.last_build_id +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Flutter.podspec +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/Flutter/flutter_export_environment.sh +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# macOS +**/macos/Flutter/GeneratedPluginRegistrant.swift +**/macos/Flutter/Flutter-Debug.xcconfig +**/macos/Flutter/Flutter-Release.xcconfig +**/macos/Flutter/Flutter-Profile.xcconfig + +# Coverage +coverage/ + +# Symbols +app.*.symbols + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +!/dev/ci/**/Gemfile.lock + +#generated file +*.g.dart +messages_all.dart +messages_en.dart +messages_fr.dart +messages_messages.dart +messages_ru.dart +messages_vi.dart \ No newline at end of file diff --git a/model/.metadata b/model/.metadata new file mode 100644 index 000000000..be81bed0e --- /dev/null +++ b/model/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: d79295af24c3ed621c33713ecda14ad196fd9c31 + channel: stable + +project_type: module diff --git a/model/README.md b/model/README.md new file mode 100644 index 000000000..37b84f85d --- /dev/null +++ b/model/README.md @@ -0,0 +1,11 @@ +# model + +A model module contains entities + +## Getting Started + +For help getting started with Flutter, view our online +[documentation](https://flutter.dev/). + +For instructions integrating Flutter modules to your existing applications, +see the [add-to-app documentation](https://flutter.dev/docs/development/add-to-app). diff --git a/model/lib/account/password.dart b/model/lib/account/password.dart new file mode 100644 index 000000000..f16dadaf9 --- /dev/null +++ b/model/lib/account/password.dart @@ -0,0 +1,10 @@ +import 'package:equatable/equatable.dart'; + +class Password with EquatableMixin { + final String value; + + Password(this.value); + + @override + List get props => [value]; +} \ No newline at end of file diff --git a/model/lib/account/user_name.dart b/model/lib/account/user_name.dart new file mode 100644 index 000000000..879f46e5e --- /dev/null +++ b/model/lib/account/user_name.dart @@ -0,0 +1,10 @@ +import 'package:equatable/equatable.dart'; + +class UserName with EquatableMixin { + final String userName; + + UserName(this.userName); + + @override + List get props => [userName]; +} \ No newline at end of file diff --git a/model/lib/mailbox/expand_mode.dart b/model/lib/mailbox/expand_mode.dart new file mode 100644 index 000000000..8dd655b88 --- /dev/null +++ b/model/lib/mailbox/expand_mode.dart @@ -0,0 +1 @@ +enum ExpandMode { COLLAPSE, EXPAND } \ No newline at end of file diff --git a/model/lib/mailbox/presentation_mailbox.dart b/model/lib/mailbox/presentation_mailbox.dart new file mode 100644 index 000000000..0494c4705 --- /dev/null +++ b/model/lib/mailbox/presentation_mailbox.dart @@ -0,0 +1,63 @@ +import 'package:equatable/equatable.dart'; +import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart'; +import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox_rights.dart'; +import 'package:model/mailbox/select_mode.dart'; + +class PresentationMailbox with EquatableMixin { + + final MailboxId id; + final MailboxName? name; + final MailboxId? parentId; + final Role? role; + final SortOrder? sortOrder; + final TotalEmails? totalEmails; + final UnreadEmails? unreadEmails; + final TotalThreads? totalThreads; + final UnreadThreads? unreadThreads; + final MailboxRights? myRights; + final IsSubscribed? isSubscribed; + final SelectMode selectMode; + + PresentationMailbox( + this.id, + { + this.name, + this.parentId, + this.role, + this.sortOrder, + this.totalEmails, + this.unreadEmails, + this.totalThreads, + this.unreadThreads, + this.myRights, + this.isSubscribed, + this.selectMode = SelectMode.INACTIVE + } + ); + + bool hasParentId() => parentId != null && parentId!.id.value.isNotEmpty; + + bool hasRole() => role != null && role!.value.isNotEmpty; + + String getCountUnReadEmails() { + if (unreadEmails == null) { + return ''; + } else { + if (unreadEmails!.value.value <= 0) { + return ''; + } else { + return unreadEmails!.value.value <= 999 + ? '${unreadEmails!.value.value}' + : '999+'; + } + } + } + + @override + List get props => [ + id, + name, + parentId, + role + ]; +} \ No newline at end of file diff --git a/model/lib/mailbox/select_mode.dart b/model/lib/mailbox/select_mode.dart new file mode 100644 index 000000000..b5d90b1a4 --- /dev/null +++ b/model/lib/mailbox/select_mode.dart @@ -0,0 +1 @@ +enum SelectMode { ACTIVE, INACTIVE } \ No newline at end of file diff --git a/model/lib/model.dart b/model/lib/model.dart new file mode 100644 index 000000000..b3da60965 --- /dev/null +++ b/model/lib/model.dart @@ -0,0 +1,13 @@ +library model; + +// Account +export 'account/user_name.dart'; +export 'account/password.dart'; + +// User +export 'user/user_id.dart'; +export 'user/user.dart'; +// Mailbox +export 'mailbox/presentation_mailbox.dart'; +export 'mailbox/select_mode.dart'; +export 'mailbox/expand_mode.dart'; diff --git a/model/lib/user/user.dart b/model/lib/user/user.dart new file mode 100644 index 000000000..9dbc8c9dc --- /dev/null +++ b/model/lib/user/user.dart @@ -0,0 +1,22 @@ +import 'package:equatable/equatable.dart'; +import 'package:model/user/user_id.dart'; + +class User with EquatableMixin { + + final UserId userId; + final String firstName; + final String lastName; + + User( + this.userId, + this.firstName, + this.lastName, + ); + + @override + List get props => [ + userId, + firstName, + lastName, + ]; +} \ No newline at end of file diff --git a/model/lib/user/user_id.dart b/model/lib/user/user_id.dart new file mode 100644 index 000000000..70bdf9d44 --- /dev/null +++ b/model/lib/user/user_id.dart @@ -0,0 +1,10 @@ +import 'package:equatable/equatable.dart'; + +class UserId with EquatableMixin { + final String id; + + UserId(this.id); + + @override + List get props => [id]; +} \ No newline at end of file diff --git a/model/pubspec.yaml b/model/pubspec.yaml new file mode 100644 index 000000000..b57e77bd4 --- /dev/null +++ b/model/pubspec.yaml @@ -0,0 +1,99 @@ +name: model +description: A model module contains entities + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# +# This version is used _only_ for the Runner app, which is used if you just do +# a `flutter run` or a `flutter make-host-app-editable`. It has no impact +# on any other native host app that you embed your Flutter project into. +version: 1.0.0+1 + +environment: + sdk: ">=2.12.0 <3.0.0" + +dependencies: + flutter: + sdk: flutter + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + + # equatable + equatable: 2.0.3 + + # quiver + quiver: 3.0.1 + + # jmap_dart_client + jmap_dart_client: + git: + url: git://github.com/hoangdat/jmap-dart-client.git + ref: serialize + +dev_dependencies: + flutter_test: + sdk: flutter + + build_runner: 2.0.5 +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +flutter: + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add Flutter specific assets to your application, add an assets section, + # like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add Flutter specific custom fonts to your application, 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 from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages + + + # This section identifies your Flutter project as a module meant for + # embedding in a native host app. These identifiers should _not_ ordinarily + # be changed after generation - they are used to ensure that the tooling can + # maintain consistency when adding or modifying assets and plugins. + # They also do not have any bearing on your native host application's + # identifiers, which may be completely independent or the same as these. + module: + androidX: true + androidPackage: com.linagora.android.tmail.model + iosBundleIdentifier: com.linagora.android.tmail.model