├── ios
├── Flutter
│ ├── Debug.xcconfig
│ ├── Release.xcconfig
│ └── AppFrameworkInfo.plist
├── Runner
│ ├── Runner-Bridging-Header.h
│ ├── Assets.xcassets
│ │ ├── LaunchImage.imageset
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ ├── README.md
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-83.5x83.5@2x.png
│ │ │ └── Contents.json
│ ├── AppDelegate.swift
│ ├── Base.lproj
│ │ ├── Main.storyboard
│ │ └── LaunchScreen.storyboard
│ └── Info.plist
├── Runner.xcworkspace
│ └── contents.xcworkspacedata
├── Runner.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ ├── xcshareddata
│ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ └── project.pbxproj
└── .gitignore
├── icons
└── icon.png
├── lib
├── src
│ └── app
│ │ ├── shared
│ │ ├── enums
│ │ │ ├── sort_criteria_enum.dart
│ │ │ └── login_enum.dart
│ │ └── blocs
│ │ │ ├── user_bloc.dart
│ │ │ └── order_bloc.dart
│ │ ├── components
│ │ ├── tabs
│ │ │ ├── users_tab
│ │ │ │ ├── users_tab_bloc.dart
│ │ │ │ ├── user_tile
│ │ │ │ │ ├── user_tile_bloc.dart
│ │ │ │ │ └── user_tile_widget.dart
│ │ │ │ └── users_tab.dart
│ │ │ ├── orders_tab
│ │ │ │ ├── order_tile
│ │ │ │ │ ├── order_tile_bloc.dart
│ │ │ │ │ ├── order_header
│ │ │ │ │ │ ├── order_header_bloc.dart
│ │ │ │ │ │ └── order_header_widget.dart
│ │ │ │ │ └── order_tile_widget.dart
│ │ │ │ ├── orders_tab_bloc.dart
│ │ │ │ └── orders_tab.dart
│ │ │ └── products_tab
│ │ │ │ ├── products_tab_bloc.dart
│ │ │ │ ├── category_tile
│ │ │ │ ├── category_tile_bloc.dart
│ │ │ │ ├── edit_category_dialog
│ │ │ │ │ ├── edit_category_dialog_bloc.dart
│ │ │ │ │ └── edit_category_dialog_widget.dart
│ │ │ │ └── category_tile_widget.dart
│ │ │ │ └── products_tab.dart
│ │ ├── imagesWidget
│ │ │ ├── images_bloc.dart
│ │ │ ├── image_source_sheet
│ │ │ │ ├── image_source_sheet_bloc.dart
│ │ │ │ └── image_source_sheet_widget.dart
│ │ │ └── images_widget.dart
│ │ ├── input_field
│ │ │ ├── input_field_bloc.dart
│ │ │ └── input_field_widget.dart
│ │ └── product_size
│ │ │ ├── product_size_bloc.dart
│ │ │ ├── add_sizes_dialog
│ │ │ ├── add_sizes_dialog_bloc.dart
│ │ │ └── add_sizes_dialog_widget.dart
│ │ │ └── product_size_widget.dart
│ │ ├── app_bloc.dart
│ │ ├── pages
│ │ ├── Home
│ │ │ ├── home_bloc.dart
│ │ │ └── home_page.dart
│ │ ├── product
│ │ │ ├── images
│ │ │ │ └── images_widget.dart
│ │ │ ├── product_bloc.dart
│ │ │ └── product_page.dart
│ │ └── login
│ │ │ ├── login_bloc.dart
│ │ │ └── login_page.dart
│ │ ├── app_widget.dart
│ │ ├── validators
│ │ ├── login_validator.dart
│ │ └── product_validator.dart
│ │ ├── repositories
│ │ ├── orders_repository.dart
│ │ ├── login_repository.dart
│ │ ├── user_repository.dart
│ │ └── product_repository.dart
│ │ └── app_module.dart
└── main.dart
├── images
└── no_image.png
├── android
├── .settings
│ └── org.eclipse.buildship.core.prefs
├── app
│ ├── .settings
│ │ └── org.eclipse.buildship.core.prefs
│ ├── src
│ │ ├── main
│ │ │ ├── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values
│ │ │ │ │ └── styles.xml
│ │ │ │ └── drawable
│ │ │ │ │ └── launch_background.xml
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── gerenciamento_loja
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── AndroidManifest.xml
│ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── .classpath
│ ├── .project
│ ├── google-services.json
│ └── build.gradle
├── gradle.properties
├── .gitignore
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── .project
├── settings.gradle
└── build.gradle
├── .metadata
├── README.md
├── .gitignore
├── pubspec.yaml
└── pubspec.lock
/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
--------------------------------------------------------------------------------
/icons/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/icons/icon.png
--------------------------------------------------------------------------------
/lib/src/app/shared/enums/sort_criteria_enum.dart:
--------------------------------------------------------------------------------
1 | enum SortCriteria { READY_FIRST, READY_LAST }
2 |
--------------------------------------------------------------------------------
/lib/src/app/shared/enums/login_enum.dart:
--------------------------------------------------------------------------------
1 | enum LoginState { INITIAL, IDLE, LOADING, SUCCESS, FAIL }
2 |
--------------------------------------------------------------------------------
/images/no_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/images/no_image.png
--------------------------------------------------------------------------------
/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/android/app/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=..
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:gerenciamento_loja/src/app/app_module.dart';
3 |
4 | void main() => runApp(AppModule());
5 |
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/toshiossada/FlutterGerenciadorLoja/HEAD/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/users_tab/users_tab_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 |
4 | class UsersTabBloc extends BlocBase {
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/app_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class AppBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/orders_tab/order_tile/order_tile_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class OrderTileBloc extends BlocBase {
4 |
5 | @override
6 | void dispose() {
7 |
8 | super.dispose();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lib/src/app/pages/Home/home_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class HomeBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
7 |
--------------------------------------------------------------------------------
/lib/src/app/components/imagesWidget/images_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class ImagesBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/components/input_field/input_field_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class InputFieldBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/components/product_size/product_size_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class ProductSizeBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/orders_tab/orders_tab_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class OrdersTabBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/users_tab/user_tile/user_tile_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class UserTileBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/components/product_size/add_sizes_dialog/add_sizes_dialog_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class AddSizesDialogBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/components/imagesWidget/image_source_sheet/image_source_sheet_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class ImageSourceSheetBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/orders_tab/order_tile/order_header/order_header_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 |
3 | class OrderHeaderBloc extends BlocBase {
4 | //dispose will be called automatically by closing its streams
5 | @override
6 | void dispose() {
7 | super.dispose();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: cc3ca9a916cb1da851a1f36432154a534787da99
8 | channel: dev
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/android/app/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/android/app/src/main/kotlin/com/example/gerenciamento_loja/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.gerenciamento_loja
2 |
3 | import android.os.Bundle
4 |
5 | import io.flutter.app.FlutterActivity
6 | import io.flutter.plugins.GeneratedPluginRegistrant
7 |
8 | class MainActivity: FlutterActivity() {
9 | override fun onCreate(savedInstanceState: Bundle?) {
10 | super.onCreate(savedInstanceState)
11 | GeneratedPluginRegistrant.registerWith(this)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | android
4 | Project android created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.buildship.core.gradleprojectbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.buildship.core.gradleprojectnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/lib/src/app/app_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:gerenciamento_loja/src/app/pages/login/login_page.dart';
3 |
4 | class AppWidget extends StatelessWidget {
5 | @override
6 | Widget build(BuildContext context) {
7 | return MaterialApp(
8 | title: 'Flutter Slidy',
9 | theme: ThemeData(
10 | primarySwatch: Colors.blue,
11 | backgroundColor: Colors.grey[850],
12 | appBarTheme: AppBarTheme(color: Colors.pinkAccent),
13 | ),
14 | home: LoginPage(),
15 | );
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/products_tab/products_tab_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 | import 'package:cloud_firestore/cloud_firestore.dart';
3 | import 'package:gerenciamento_loja/src/app/app_module.dart';
4 | import 'package:gerenciamento_loja/src/app/repositories/product_repository.dart';
5 |
6 | class ProductsTabBloc extends BlocBase {
7 | final _productRepository = AppModule.to.getDependency();
8 |
9 | Stream getDocuments() {
10 | return _productRepository.getDocuments();
11 | }
12 |
13 | @override
14 | void dispose() {
15 | super.dispose();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # gerenciamento_loja
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 | "# FlutterGerenciadorLoja"
18 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Generated.xcconfig
20 | Flutter/app.flx
21 | Flutter/app.zip
22 | Flutter/flutter_assets/
23 | Flutter/flutter_export_environment.sh
24 | ServiceDefinitions.json
25 | Runner/GeneratedPluginRegistrant.*
26 |
27 | # Exceptions to above rules.
28 | !default.mode1v3
29 | !default.mode2v3
30 | !default.pbxuser
31 | !default.perspectivev3
32 |
--------------------------------------------------------------------------------
/lib/src/app/validators/login_validator.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | class LoginValidator {
4 | final validateEmail = StreamTransformer.fromHandlers(
5 | handleData: (email, sink) async {
6 | if (RegExp(r"^[a-zA-Z0-9._]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email)) sink.add(email);
7 | else sink.addError('Insira um email valido');
8 | },
9 | );
10 | final validatePass = StreamTransformer.fromHandlers(
11 | handleData: (pass, sink) async {
12 | if (pass.length >= 4) sink.add(pass);
13 | else sink.addError('Senha inválida! Senha deve conter pelo menos 4 caracters');
14 | },
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/android/app/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | app
4 | Project app created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .packages
28 | .pub-cache/
29 | .pub/
30 | /build/
31 |
32 | # Web related
33 | lib/generated_plugin_registrant.dart
34 |
35 | # Exceptions to above rules.
36 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
37 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.50'
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.5.0'
10 | classpath 'com.google.gms:google-services:4.3.0'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | google()
18 | jcenter()
19 | }
20 | }
21 |
22 | rootProject.buildDir = '../build'
23 | subprojects {
24 | project.buildDir = "${rootProject.buildDir}/${project.name}"
25 | }
26 | subprojects {
27 | project.evaluationDependsOn(':app')
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/lib/src/app/validators/product_validator.dart:
--------------------------------------------------------------------------------
1 | class ProductValidator {
2 |
3 | String validateImages(List images){
4 | if(images.isEmpty) return "Adicione imagens do produto";
5 | return null;
6 | }
7 |
8 | String validateTitle(String text){
9 | if(text.isEmpty) return "Preencha o título do produto";
10 | return null;
11 | }
12 |
13 | String validateDescription(String text){
14 | if(text.isEmpty) return "Preencha a descrição do produto";
15 | return null;
16 | }
17 |
18 | String validatePrice(String text){
19 | double price = double.tryParse(text);
20 | if(price != null){
21 | if(!text.contains(".") || text.split(".")[1].length != 2)
22 | return "Utilize 2 casas decimais";
23 | } else {
24 | return "Preço inválido";
25 | }
26 | return null;
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/products_tab/category_tile/category_tile_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 | import 'package:cloud_firestore/cloud_firestore.dart';
3 | import 'package:gerenciamento_loja/src/app/app_module.dart';
4 | import 'package:gerenciamento_loja/src/app/repositories/product_repository.dart';
5 |
6 | class CategoryTileBloc extends BlocBase {
7 | final _productRepository = AppModule.to.getDependency();
8 |
9 | Future getItems(DocumentSnapshot category) {
10 | return _productRepository.getItems(category);
11 | }
12 |
13 | deleteProduct(DocumentSnapshot p) {
14 | p.reference.delete();
15 | }
16 |
17 | //dispose will be called automatically by closing its streams
18 | @override
19 | void dispose() {
20 | super.dispose();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/lib/src/app/repositories/orders_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 | import 'package:cloud_firestore/cloud_firestore.dart';
3 |
4 | class OrderRepository extends Disposable {
5 | var _firestore = Firestore.instance;
6 | final String _colletion = 'orders';
7 |
8 | Future get({String documentId}) async {
9 | return await _firestore.collection(_colletion).document(documentId).get();
10 | }
11 |
12 | addListener(Function f) {
13 | _firestore.collection(_colletion).snapshots().listen(f);
14 | }
15 |
16 | void updateData(DocumentSnapshot order, String field, dynamic value) {
17 | order.reference.updateData({field: value});
18 | }
19 |
20 | void delete(DocumentSnapshot order){
21 | order.reference.delete();
22 | }
23 |
24 |
25 | @override
26 | void dispose() {}
27 | }
28 |
--------------------------------------------------------------------------------
/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lib/src/app/repositories/login_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 | import 'package:cloud_firestore/cloud_firestore.dart';
3 | import 'package:firebase_auth/firebase_auth.dart';
4 | import 'package:flutter/foundation.dart';
5 |
6 | class LoginRepository extends Disposable {
7 | FirebaseAuth instance = FirebaseAuth.instance;
8 | Firestore get firestore => Firestore.instance;
9 |
10 | Future login(
11 | {@required String email, @required String pass}) async {
12 | var result =
13 | await instance.signInWithEmailAndPassword(email: email, password: pass);
14 | return result;
15 | }
16 |
17 | Future verifyPrivileges(FirebaseUser user) async {
18 | var result = await firestore.collection('admins').document(user.uid).get();
19 | return result;
20 | }
21 |
22 | //dispose will be called automatically by closing its streams
23 | @override
24 | void dispose() {}
25 | }
26 |
--------------------------------------------------------------------------------
/lib/src/app/repositories/user_repository.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 | import 'package:cloud_firestore/cloud_firestore.dart';
3 |
4 | class UserRepository extends Disposable {
5 | var _firestore = Firestore.instance;
6 | final String _colletion = 'users';
7 |
8 | subscribleToOrders(String uid, Function f) {
9 | _firestore
10 | .collection(_colletion)
11 | .document(uid)
12 | .collection('orders')
13 | .snapshots()
14 | .listen(f);
15 | }
16 |
17 | addListener(Function f) {
18 | _firestore.collection(_colletion).snapshots().listen(f);
19 | }
20 |
21 | Future getUser(String uid) async{
22 | return await _firestore.collection(_colletion).document(uid).get();
23 | }
24 |
25 | deleteOrders(String uid, String oid) async{
26 | return await _firestore.collection(_colletion).document(uid).collection('orders').document(oid).delete();
27 | }
28 |
29 | @override
30 | void dispose() {}
31 | }
32 |
--------------------------------------------------------------------------------
/lib/src/app/components/product_size/add_sizes_dialog/add_sizes_dialog_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class AddSizesDialogWidget extends StatelessWidget {
4 | final _controller = TextEditingController();
5 |
6 | @override
7 | Widget build(BuildContext context) {
8 | return Dialog(
9 | child: Container(
10 | padding: EdgeInsets.only(left: 8, right: 8, top: 8),
11 | child: Column(
12 | mainAxisSize: MainAxisSize.min,
13 | children: [
14 | TextField(
15 | controller: _controller,
16 |
17 | ),
18 | Container(
19 | alignment: Alignment.centerRight,
20 | child: FlatButton(
21 | child: Text('Add'),
22 | textColor: Colors.pinkAccent,
23 | onPressed: () {
24 | Navigator.pop(context, _controller.text);
25 | },
26 | ),
27 | ),
28 | ],
29 | )),
30 | );
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/products_tab/products_tab.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:gerenciamento_loja/src/app/app_module.dart';
3 |
4 | import 'category_tile/category_tile_widget.dart';
5 | import 'products_tab_bloc.dart';
6 |
7 | class ProductsTab extends StatefulWidget {
8 | @override
9 | _ProductsTabState createState() => _ProductsTabState();
10 | }
11 |
12 | class _ProductsTabState extends State with AutomaticKeepAliveClientMixin{
13 | final _productBloc = AppModule.to.getBloc();
14 |
15 | @override
16 | Widget build(BuildContext context) {
17 | super.build(context);
18 |
19 | return StreamBuilder(
20 | stream: _productBloc.getDocuments(),
21 | builder: (context, snapshot) {
22 | if (!snapshot.hasData)
23 | return Center(
24 | child: CircularProgressIndicator(
25 | valueColor: AlwaysStoppedAnimation(Colors.white),
26 | ),
27 | );
28 | else
29 | return ListView.builder(
30 | itemCount: snapshot.data.documents.length,
31 | itemBuilder: (context, index) =>
32 | CategoryTileWidget(snapshot.data.documents[index]),
33 | );
34 | },
35 | );
36 | }
37 |
38 | @override
39 | bool get wantKeepAlive => true;
40 | }
41 |
--------------------------------------------------------------------------------
/lib/src/app/components/input_field/input_field_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class InputField extends StatelessWidget {
4 | final IconData icon;
5 | final bool obscure;
6 | final String hint;
7 | final Stream stream;
8 | final Function(String) onChanged;
9 |
10 | InputField(
11 | {@required this.icon,
12 | @required this.hint,
13 | @required this.obscure,
14 | @required this.stream,
15 | @required this.onChanged});
16 |
17 | @override
18 | Widget build(BuildContext context) {
19 | return StreamBuilder(
20 | stream: stream,
21 | builder: (context, snapshot) {
22 | return TextField(
23 | onChanged: onChanged,
24 | decoration: InputDecoration(
25 | icon: Icon(
26 | icon,
27 | color: Colors.white,
28 | ),
29 | hintText: hint,
30 | hintStyle: TextStyle(color: Colors.white),
31 | focusedBorder: UnderlineInputBorder(
32 | borderSide: BorderSide(color: Colors.pinkAccent),
33 | ),
34 | contentPadding:
35 | EdgeInsets.only(left: 5, top: 30, bottom: 30, right: 30),
36 | errorText: snapshot.hasError ? snapshot.error : null,
37 | ),
38 | style: TextStyle(color: Colors.white),
39 | obscureText: obscure,
40 | );
41 | },
42 | );
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/orders_tab/orders_tab.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:gerenciamento_loja/src/app/app_module.dart';
3 | import 'package:gerenciamento_loja/src/app/shared/blocs/order_bloc.dart';
4 |
5 | import 'order_tile/order_tile_widget.dart';
6 |
7 | class OrdersTab extends StatelessWidget {
8 | final _ordersBloc = AppModule.to.getBloc();
9 |
10 | @override
11 | Widget build(BuildContext context) {
12 | return Padding(
13 | padding: EdgeInsets.symmetric(vertical: 16),
14 | child: StreamBuilder(
15 | stream: _ordersBloc.outOrders,
16 | builder: (context, snapshot) {
17 | if (!snapshot.hasData)
18 | return Center(
19 | child: CircularProgressIndicator(
20 | valueColor: AlwaysStoppedAnimation(Colors.pinkAccent),
21 | ),
22 | );
23 | else if (snapshot.data.length == 0)
24 | return Center(
25 | child: Text(
26 | 'Nenhum pedido encontrado!',
27 | style: TextStyle(color: Colors.pinkAccent),
28 | ),
29 | );
30 | else
31 | return ListView.builder(
32 | itemCount: snapshot.data.length,
33 | itemBuilder: (context, index) {
34 | return OrderTileWidget(snapshot.data[index]);
35 | },
36 | );
37 | },
38 | ),
39 | );
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/orders_tab/order_tile/order_header/order_header_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:cloud_firestore/cloud_firestore.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:gerenciamento_loja/src/app/app_module.dart';
4 | import 'package:gerenciamento_loja/src/app/shared/blocs/user_bloc.dart';
5 |
6 | class OrderHeaderWidget extends StatelessWidget {
7 | final DocumentSnapshot order;
8 | final _userBloc = AppModule.to.getBloc();
9 |
10 | OrderHeaderWidget(this.order);
11 |
12 | @override
13 | Widget build(BuildContext context) {
14 | var user = _userBloc.getUser(order.data['clientId']);
15 | return Row(
16 | children: [
17 | Expanded(
18 | child: Column(
19 | crossAxisAlignment: CrossAxisAlignment.start,
20 | children: [
21 | Text(user['name']),
22 | Text(user['address']),
23 | ],
24 | ),
25 | ),
26 | Column(
27 | crossAxisAlignment: CrossAxisAlignment.end,
28 | children: [
29 | Text(
30 | 'Produtos: R\$${order.data['produtcsPrice'].toStringAsFixed(2)}',
31 | style: TextStyle(fontWeight: FontWeight.w500),
32 | ),
33 | Text(
34 | 'Total R\$${order.data['totalPrice'].toStringAsFixed(2)} ',
35 | style: TextStyle(fontWeight: FontWeight.w500),
36 | ),
37 | ],
38 | ),
39 | ],
40 | );
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/lib/src/app/repositories/product_repository.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:bloc_pattern/bloc_pattern.dart';
4 | import 'package:cloud_firestore/cloud_firestore.dart';
5 | import 'package:firebase_storage/firebase_storage.dart';
6 |
7 | class ProductRepository extends Disposable {
8 | var _firestore = Firestore.instance;
9 | final String _colletion = 'products';
10 |
11 | addListener(Function f) {
12 | _firestore.collection(_colletion).snapshots().listen(f);
13 | }
14 |
15 | Stream getDocuments() {
16 | return _firestore.collection(_colletion).snapshots();
17 | }
18 |
19 | Future getItems(DocumentSnapshot category) {
20 | return category.reference.collection('items').getDocuments();
21 | }
22 |
23 | Future uploadImage(
24 | String categoryId, String productsId, File image) async {
25 | StorageUploadTask uploadTask = FirebaseStorage.instance
26 | .ref()
27 | .child(categoryId)
28 | .child(productsId)
29 | .child(DateTime.now().millisecondsSinceEpoch.toString())
30 | .putFile(image);
31 | StorageTaskSnapshot s = await uploadTask.onComplete;
32 |
33 | return await s.ref.getDownloadURL();
34 | }
35 |
36 | Future add(
37 | String categoryId, Map product) async {
38 | return await _firestore
39 | .collection(_colletion)
40 | .document(categoryId)
41 | .collection('items')
42 | .add(product);
43 | }
44 |
45 | @override
46 | void dispose() {}
47 | }
48 |
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | gerenciamento_loja
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/lib/src/app/components/imagesWidget/image_source_sheet/image_source_sheet_widget.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:image_cropper/image_cropper.dart';
5 | import 'package:image_picker/image_picker.dart';
6 |
7 | class ImageSourceSheetWidget extends StatelessWidget {
8 | final Function(File) onImageSelected;
9 |
10 | ImageSourceSheetWidget({this.onImageSelected});
11 |
12 | void imageSelected(File image) async {
13 | if (image != null) {
14 | File croppedImage = await ImageCropper.cropImage(
15 | sourcePath: image.path,
16 | aspectRatioPresets: [
17 | CropAspectRatioPreset.square,
18 | CropAspectRatioPreset.ratio3x2,
19 | CropAspectRatioPreset.original,
20 | CropAspectRatioPreset.ratio4x3,
21 | CropAspectRatioPreset.ratio16x9
22 | ],
23 | iosUiSettings: IOSUiSettings(
24 | minimumAspectRatio: 1.0,
25 | ),
26 | );
27 | onImageSelected(croppedImage);
28 | }
29 | }
30 |
31 | @override
32 | Widget build(BuildContext context) {
33 | return BottomSheet(
34 | onClosing: () {},
35 | builder: (context) => Column(
36 | mainAxisSize: MainAxisSize.min,
37 | children: [
38 | FlatButton(
39 | child: Text("Câmera"),
40 | onPressed: () async {
41 | File image =
42 | await ImagePicker.pickImage(source: ImageSource.camera);
43 | imageSelected(image);
44 | },
45 | ),
46 | FlatButton(
47 | child: Text("Galeria"),
48 | onPressed: () async {
49 | File image =
50 | await ImagePicker.pickImage(source: ImageSource.gallery);
51 | imageSelected(image);
52 | },
53 | )
54 | ],
55 | ),
56 | );
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
13 |
20 |
24 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/users_tab/user_tile/user_tile_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:shimmer/shimmer.dart';
3 |
4 | class UserTileWidget extends StatelessWidget {
5 | final Map user;
6 |
7 | UserTileWidget(this.user);
8 |
9 | var style = TextStyle(color: Colors.white);
10 | @override
11 | Widget build(BuildContext context) {
12 | if (user.containsKey('money'))
13 | return ListTile(
14 | title: Text(
15 | user['name'],
16 | style: style,
17 | ),
18 | subtitle: Text(
19 | user['email'],
20 | style: style,
21 | ),
22 | trailing: Column(
23 | crossAxisAlignment: CrossAxisAlignment.end,
24 | children: [
25 | Text(
26 | 'Pedidos: ${user['orders']}',
27 | style: style,
28 | ),
29 | Text(
30 | 'Gasto: R\$${user['money'].toStringAsFixed(2)}',
31 | style: style,
32 | )
33 | ],
34 | ),
35 | );
36 | else
37 | return Container(
38 | margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
39 | child: Column(
40 | crossAxisAlignment: CrossAxisAlignment.start,
41 | children: [
42 | SizedBox(
43 | height: 20,
44 | width: 200,
45 | child: Shimmer.fromColors(
46 | child: Container(
47 | color: Colors.white.withAlpha(200),
48 | margin: EdgeInsets.symmetric(vertical: 4),
49 | ),
50 | baseColor: Colors.white,
51 | highlightColor: Colors.grey,
52 | ),
53 | ),
54 | SizedBox(
55 | height: 20,
56 | width: 50,
57 | child: Shimmer.fromColors(
58 | child: Container(
59 | color: Colors.white.withAlpha(200),
60 | margin: EdgeInsets.symmetric(vertical: 4),
61 | ),
62 | baseColor: Colors.white,
63 | highlightColor: Colors.grey,
64 | ),
65 | ),
66 | ],
67 | ),
68 | );
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/users_tab/users_tab.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:gerenciamento_loja/src/app/app_module.dart';
3 | import 'package:gerenciamento_loja/src/app/shared/blocs/user_bloc.dart';
4 |
5 | import 'user_tile/user_tile_widget.dart';
6 |
7 | class UsersTab extends StatelessWidget {
8 | var _userBloc = AppModule.to.getBloc();
9 |
10 | @override
11 | Widget build(BuildContext context) {
12 | return Column(
13 | children: [
14 | Padding(
15 | padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
16 | child: TextField(
17 | onChanged: (value){
18 | _userBloc.onChangedSearch(value);
19 | },
20 | style: TextStyle(color: Colors.white),
21 | decoration: InputDecoration(
22 | hintText: "Pesquisar",
23 | hintStyle: TextStyle(color: Colors.white),
24 | icon: Icon(
25 | Icons.search,
26 | color: Colors.white,
27 | ),
28 | border: InputBorder.none),
29 | ),
30 | ),
31 | Expanded(
32 | child: StreamBuilder(
33 | stream: _userBloc.outUsers,
34 | builder: (context, snapshot) {
35 | if (!snapshot.hasData)
36 | return Center(
37 | child: CircularProgressIndicator(
38 | valueColor: AlwaysStoppedAnimation(Colors.pinkAccent),
39 | ),
40 | );
41 | else if (snapshot.data.length == 0)
42 | return Center(
43 | child: Text(
44 | 'Nenhum usuário encontrado',
45 | style: TextStyle(color: Colors.pinkAccent),
46 | ),
47 | );
48 | else
49 | return ListView.separated(
50 | itemBuilder: (context, index) => UserTileWidget(snapshot.data[index]),
51 | separatorBuilder: (context, index) => Divider(),
52 | itemCount: snapshot.data.length,
53 | );
54 | }),
55 | )
56 | ],
57 | );
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/android/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "869296241215",
4 | "firebase_url": "https://lojaflutter-e2b4c.firebaseio.com",
5 | "project_id": "lojaflutter-e2b4c",
6 | "storage_bucket": "lojaflutter-e2b4c.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:869296241215:android:6e4f46bb09ecae200dd68a",
12 | "android_client_info": {
13 | "package_name": "com.example.gerenciamento_loja"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "869296241215-ii06gnpm5pl88uhvbvi6dsl4u4ca6759.apps.googleusercontent.com",
19 | "client_type": 3
20 | }
21 | ],
22 | "api_key": [
23 | {
24 | "current_key": "AIzaSyBuhPyTAUGc74ywP5FUc365zvB-rJnlURI"
25 | }
26 | ],
27 | "services": {
28 | "appinvite_service": {
29 | "other_platform_oauth_client": [
30 | {
31 | "client_id": "869296241215-ii06gnpm5pl88uhvbvi6dsl4u4ca6759.apps.googleusercontent.com",
32 | "client_type": 3
33 | }
34 | ]
35 | }
36 | }
37 | },
38 | {
39 | "client_info": {
40 | "mobilesdk_app_id": "1:869296241215:android:0c439b8f49a749410dd68a",
41 | "android_client_info": {
42 | "package_name": "com.example.loja_virtual"
43 | }
44 | },
45 | "oauth_client": [
46 | {
47 | "client_id": "869296241215-ii06gnpm5pl88uhvbvi6dsl4u4ca6759.apps.googleusercontent.com",
48 | "client_type": 3
49 | }
50 | ],
51 | "api_key": [
52 | {
53 | "current_key": "AIzaSyBuhPyTAUGc74ywP5FUc365zvB-rJnlURI"
54 | }
55 | ],
56 | "services": {
57 | "appinvite_service": {
58 | "other_platform_oauth_client": [
59 | {
60 | "client_id": "869296241215-ii06gnpm5pl88uhvbvi6dsl4u4ca6759.apps.googleusercontent.com",
61 | "client_type": 3
62 | }
63 | ]
64 | }
65 | }
66 | }
67 | ],
68 | "configuration_version": "1"
69 | }
--------------------------------------------------------------------------------
/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 28
30 |
31 | sourceSets {
32 | main.java.srcDirs += 'src/main/kotlin'
33 | }
34 |
35 | lintOptions {
36 | disable 'InvalidPackage'
37 | }
38 |
39 | defaultConfig {
40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41 | applicationId "com.example.gerenciamento_loja"
42 | minSdkVersion 23
43 | targetSdkVersion 28
44 | versionCode flutterVersionCode.toInteger()
45 | versionName flutterVersionName
46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
47 | }
48 |
49 | buildTypes {
50 | release {
51 | // TODO: Add your own signing config for the release build.
52 | // Signing with the debug keys for now, so `flutter run --release` works.
53 | signingConfig signingConfigs.debug
54 | }
55 | }
56 | }
57 |
58 | flutter {
59 | source '../..'
60 | }
61 |
62 | dependencies {
63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64 | testImplementation 'junit:junit:4.12'
65 | androidTestImplementation 'androidx.test:runner:1.1.1'
66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
67 | }
68 | apply plugin: 'com.google.gms.google-services'
--------------------------------------------------------------------------------
/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/lib/src/app/components/imagesWidget/images_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | import 'image_source_sheet/image_source_sheet_widget.dart';
4 |
5 |
6 |
7 | class ImagesWidget extends FormField {
8 |
9 | ImagesWidget({
10 | BuildContext context,
11 | FormFieldSetter onSaved,
12 | FormFieldValidator validator,
13 | List initialValue,
14 | bool autoValidate = false,
15 | }) : super(
16 | onSaved: onSaved,
17 | validator: validator,
18 | initialValue: initialValue,
19 | autovalidate: autoValidate,
20 | builder: (state){
21 | return Column(
22 | crossAxisAlignment: CrossAxisAlignment.start,
23 | children: [
24 | Container(
25 | height: 124,
26 | padding: EdgeInsets.only(top: 16, bottom: 8),
27 | child: ListView(
28 | scrollDirection: Axis.horizontal,
29 | children: state.value.map((i){
30 | return Container(
31 | height: 100,
32 | width: 100,
33 | margin: EdgeInsets.only(right: 8),
34 | child: GestureDetector(
35 | child: i is String ? Image.network(i, fit: BoxFit.cover,) :
36 | Image.file(i, fit: BoxFit.cover,),
37 | onLongPress: (){
38 | state.didChange(state.value..remove(i));
39 | },
40 | ),
41 | );
42 | }).toList()..add(
43 | GestureDetector(
44 | child: Container(
45 | height: 100,
46 | width: 100,
47 | child: Icon(Icons.camera_enhance, color: Colors.white,),
48 | color: Colors.white.withAlpha(50),
49 | ),
50 | onTap: (){
51 | showModalBottomSheet(context: context,
52 | builder: (context) => ImageSourceSheetWidget(
53 | onImageSelected: (image){
54 | state.didChange(state.value..add(image));
55 | Navigator.of(context).pop();
56 | },
57 | )
58 | );
59 | },
60 | )
61 | ),
62 | ),
63 | ),
64 | state.hasError ? Text(
65 | state.errorText,
66 | style: TextStyle(
67 | color: Colors.red,
68 | fontSize: 12
69 | ),
70 | ) : Container()
71 | ],
72 | );
73 | }
74 | );
75 |
76 | }
--------------------------------------------------------------------------------
/lib/src/app/pages/product/images/images_widget.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:gerenciamento_loja/src/app/components/imagesWidget/image_source_sheet/image_source_sheet_widget.dart';
3 |
4 |
5 |
6 |
7 |
8 | class ImagesWidget extends FormField {
9 |
10 | ImagesWidget({
11 | BuildContext context,
12 | FormFieldSetter onSaved,
13 | FormFieldValidator validator,
14 | List initialValue,
15 | bool autoValidate = false,
16 | }) : super(
17 | onSaved: onSaved,
18 | validator: validator,
19 | initialValue: initialValue,
20 | autovalidate: autoValidate,
21 | builder: (state){
22 | return Column(
23 | crossAxisAlignment: CrossAxisAlignment.start,
24 | children: [
25 | Container(
26 | height: 124,
27 | padding: EdgeInsets.only(top: 16, bottom: 8),
28 | child: ListView(
29 | scrollDirection: Axis.horizontal,
30 | children: state.value.map((i){
31 | return Container(
32 | height: 100,
33 | width: 100,
34 | margin: EdgeInsets.only(right: 8),
35 | child: GestureDetector(
36 | child: i is String ? Image.network(i, fit: BoxFit.cover,) :
37 | Image.file(i, fit: BoxFit.cover,),
38 | onLongPress: (){
39 | state.didChange(state.value..remove(i));
40 | },
41 | ),
42 | );
43 | }).toList()..add(
44 | GestureDetector(
45 | child: Container(
46 | height: 100,
47 | width: 100,
48 | child: Icon(Icons.camera_enhance, color: Colors.white,),
49 | color: Colors.white.withAlpha(50),
50 | ),
51 | onTap: (){
52 | showModalBottomSheet(context: context,
53 | builder: (context) => ImageSourceSheetWidget(
54 | onImageSelected: (image){
55 | state.didChange(state.value..add(image));
56 | Navigator.of(context).pop();
57 | },
58 | )
59 | );
60 | },
61 | )
62 | ),
63 | ),
64 | ),
65 | state.hasError ? Text(
66 | state.errorText,
67 | style: TextStyle(
68 | color: Colors.red,
69 | fontSize: 12
70 | ),
71 | ) : Container()
72 | ],
73 | );
74 | }
75 | );
76 |
77 | }
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/lib/src/app/components/tabs/products_tab/category_tile/edit_category_dialog/edit_category_dialog_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:bloc_pattern/bloc_pattern.dart';
5 | import 'package:cloud_firestore/cloud_firestore.dart';
6 | import 'package:firebase_storage/firebase_storage.dart';
7 | import 'package:rxdart/rxdart.dart';
8 |
9 | class EditCategoryDialogBloc extends BlocBase {
10 | final _titleController = BehaviorSubject();
11 | final _imageController = BehaviorSubject();
12 | final _deleteController = BehaviorSubject();
13 |
14 | File image;
15 | String title;
16 |
17 | Stream get outTitle => _titleController.stream
18 | .transform(StreamTransformer.fromHandlers(
19 | handleData: (title, sink) {
20 | if (title.isEmpty)
21 | sink.addError('Insira um titulo');
22 | else
23 | sink.add(title);
24 | },
25 | ));
26 | Stream get outImages => _imageController.stream;
27 | Stream get outDelete => _deleteController.stream;
28 | Stream get submitValid =>
29 | Observable.combineLatest2(outTitle, outImages, (a, b) => true);
30 |
31 | DocumentSnapshot category;
32 | init(DocumentSnapshot c) {
33 | category = c;
34 |
35 | if (category != null) {
36 | title = category.data['title'];
37 | image = category.data['icon'];
38 |
39 | _titleController.add(category.data['title']);
40 | _imageController.add(category.data['icon']);
41 | _deleteController.add(true);
42 | } else {
43 | _deleteController.add(false);
44 | }
45 | }
46 |
47 | setImage(File file) {
48 | image = file;
49 | _imageController.add(file);
50 | }
51 |
52 | setTitle(String title) {
53 | this.title = title;
54 |
55 | _titleController.add(title);
56 | }
57 |
58 | savaData() async {
59 | if (image == null && category == null && title == category.data['title'])
60 | return;
61 | Map dataToUpdate = {};
62 |
63 | if (image != null) {
64 | StorageUploadTask task = FirebaseStorage.instance
65 | .ref()
66 | .child('icons')
67 | .child(title)
68 | .putFile(image);
69 | StorageTaskSnapshot snap = await task.onComplete;
70 |
71 | dataToUpdate['icon'] = await snap.ref.getDownloadURL();
72 | }
73 | if (category == null || title != category.data['title']) {
74 | dataToUpdate['title'] = title;
75 | }
76 |
77 | if (category == null) {
78 | await Firestore.instance
79 | .collection('products')
80 | .document(title.toLowerCase())
81 | .setData(dataToUpdate);
82 | } else {
83 | await category.reference.updateData(dataToUpdate);
84 | }
85 | }
86 |
87 | delete(){
88 | category.reference.delete();
89 | }
90 |
91 | //dispose will be called automatically by closing its streams
92 | @override
93 | void dispose() {
94 | _titleController.close();
95 | _imageController.close();
96 | _deleteController.close();
97 | super.dispose();
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/lib/src/app/shared/blocs/user_bloc.dart:
--------------------------------------------------------------------------------
1 | import 'package:bloc_pattern/bloc_pattern.dart';
2 | import 'package:cloud_firestore/cloud_firestore.dart';
3 | import 'package:gerenciamento_loja/src/app/app_module.dart';
4 | import 'package:gerenciamento_loja/src/app/repositories/orders_repository.dart';
5 | import 'package:gerenciamento_loja/src/app/repositories/user_repository.dart';
6 | import 'package:rxdart/rxdart.dart';
7 |
8 | class UserBloc extends BlocBase {
9 |
10 | final _usersController = BehaviorSubject();
11 | Map> _users = {};
12 | var _userRepository = AppModule.to.getDependency();
13 | var _ordersRepository = AppModule.to.getDependency();
14 |
15 | Stream get outUsers => _usersController.stream;
16 |
17 | UserBloc() {
18 | _addUsersListener();
19 | }
20 | _addUsersListener() {
21 | _userRepository.addListener((QuerySnapshot snapshot) {
22 | snapshot.documentChanges.forEach((change) {
23 | var uid = change.document.documentID;
24 |
25 | switch (change.type) {
26 | case DocumentChangeType.added:
27 | _users[uid] = change.document.data;
28 | _subscribleToOrders(uid);
29 | break;
30 | case DocumentChangeType.modified:
31 | _users[uid].addAll(change.document.data);
32 | _usersController.add(_users.values.toList());
33 | break;
34 | case DocumentChangeType.removed:
35 | _users.remove(uid);
36 | _unsubscribleToOrders(uid);
37 | _usersController.add(_users.values.toList());
38 | break;
39 | }
40 | });
41 | });
42 | }
43 |
44 | _subscribleToOrders(String uid) {
45 | _users[uid]['subscription'] =
46 | _userRepository.subscribleToOrders(uid, (QuerySnapshot orders) async {
47 | var numOrders = orders.documents.length;
48 |
49 | var money = 0.0;
50 |
51 | for (DocumentSnapshot d in orders.documents) {
52 | var order = await _ordersRepository.get(documentId: d.documentID);
53 |
54 | if (order.data == null) continue;
55 |
56 | money += order.data['totalPrice'];
57 | }
58 |
59 | _users[uid].addAll({'money': money, 'orders': numOrders});
60 |
61 | _usersController.add(_users.values.toList());
62 | });
63 | }
64 |
65 | _unsubscribleToOrders(String uid) {
66 | _users[uid]['subscription'].cancel();
67 | }
68 |
69 | @override
70 | void dispose() {
71 | _usersController.close();
72 | super.dispose();
73 | }
74 |
75 | void onChangedSearch(String search) {
76 | if (search.trim().isEmpty) {
77 | _usersController.add(_users.values.toList());
78 | } else {
79 | _usersController.add(_filter(search.trim()));
80 | }
81 | }
82 |
83 | Map getUser(String uid) {
84 | return _users[uid];
85 | }
86 |
87 | List