feat: Agente Ventas SIGMAC — app de rutas y pedidos de campo
App Flutter 2.11 para vendedores de ruta de Telcotronics. Incluye ruta del día con mapa custom, catálogo, pedidos CRUD, firma digital, scanner QR/barcode, selector de clientes escalable, notificaciones in-app y soporte multiplataforma (Android + Linux desktop). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@@ -0,0 +1,49 @@
|
|||||||
|
# Miscellaneous
|
||||||
|
*.class
|
||||||
|
*.log
|
||||||
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
.DS_Store
|
||||||
|
.atom/
|
||||||
|
.buildlog/
|
||||||
|
.history
|
||||||
|
.svn/
|
||||||
|
|
||||||
|
# IntelliJ related
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# 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/
|
||||||
|
|
||||||
|
# Flutter/Dart/Pub related
|
||||||
|
**/doc/api/
|
||||||
|
**/ios/Flutter/.last_build_id
|
||||||
|
.dart_tool/
|
||||||
|
.flutter-plugins
|
||||||
|
.flutter-plugins-dependencies
|
||||||
|
.packages
|
||||||
|
.pub-cache/
|
||||||
|
.pub/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
# Web related
|
||||||
|
lib/generated_plugin_registrant.dart
|
||||||
|
|
||||||
|
# Symbolication related
|
||||||
|
app.*.symbols
|
||||||
|
|
||||||
|
# Obfuscation related
|
||||||
|
app.*.map.json
|
||||||
|
|
||||||
|
# Android Studio will place build artifacts here
|
||||||
|
/android/app/debug
|
||||||
|
/android/app/profile
|
||||||
|
/android/app/release
|
||||||
|
|
||||||
|
# Documentación interna de agentes IA (contiene IPs y credenciales)
|
||||||
|
.agente/
|
||||||
@@ -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: b101bfe32f634566e7cb2791a9efe19cf8828b15
|
||||||
|
channel: dev
|
||||||
|
|
||||||
|
project_type: app
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# pedidos_app
|
||||||
|
|
||||||
|
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://flutter.dev/docs/get-started/codelab)
|
||||||
|
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
|
||||||
|
|
||||||
|
For help getting started with Flutter, view our
|
||||||
|
[online documentation](https://flutter.dev/docs), which offers tutorials,
|
||||||
|
samples, guidance on mobile development, and a full API reference.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# This file configures the analyzer, which statically analyzes Dart code to
|
||||||
|
# check for errors, warnings, and lints.
|
||||||
|
#
|
||||||
|
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
||||||
|
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
||||||
|
# invoked from the command line by running `flutter analyze`.
|
||||||
|
|
||||||
|
# The following line activates a set of recommended lints for Flutter apps,
|
||||||
|
# packages, and plugins designed to encourage good coding practices.
|
||||||
|
include: package:flutter_lints/flutter.yaml
|
||||||
|
|
||||||
|
linter:
|
||||||
|
# The lint rules applied to this project can be customized in the
|
||||||
|
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
||||||
|
# included above or to enable additional rules. A list of all available lints
|
||||||
|
# and their documentation is published at
|
||||||
|
# https://dart-lang.github.io/linter/lints/index.html.
|
||||||
|
#
|
||||||
|
# Instead of disabling a lint rule for the entire project in the
|
||||||
|
# section below, it can also be suppressed for a single line of code
|
||||||
|
# or a specific dart file by using the `// ignore: name_of_lint` and
|
||||||
|
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
||||||
|
# producing the lint.
|
||||||
|
rules:
|
||||||
|
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||||
|
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||||
|
|
||||||
|
# Additional information about this file can be found at
|
||||||
|
# https://dart.dev/guides/language/analysis-options
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
gradle-wrapper.jar
|
||||||
|
/.gradle
|
||||||
|
/captures/
|
||||||
|
/gradlew
|
||||||
|
/gradlew.bat
|
||||||
|
/local.properties
|
||||||
|
GeneratedPluginRegistrant.java
|
||||||
|
|
||||||
|
# Remember to never publicly share your keystore.
|
||||||
|
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
|
||||||
|
key.properties
|
||||||
|
**/*.keystore
|
||||||
|
**/*.jks
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
def localProperties = new Properties()
|
||||||
|
def localPropertiesFile = rootProject.file('local.properties')
|
||||||
|
if (localPropertiesFile.exists()) {
|
||||||
|
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||||
|
localProperties.load(reader)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||||
|
if (flutterRoot == null) {
|
||||||
|
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||||||
|
if (flutterVersionCode == null) {
|
||||||
|
flutterVersionCode = '1'
|
||||||
|
}
|
||||||
|
|
||||||
|
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||||||
|
if (flutterVersionName == null) {
|
||||||
|
flutterVersionName = '1.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion flutter.compileSdkVersion
|
||||||
|
ndkVersion flutter.ndkVersion
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '1.8'
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
|
applicationId "com.sigmac.agenteventas"
|
||||||
|
minSdkVersion flutter.minSdkVersion
|
||||||
|
targetSdkVersion flutter.targetSdkVersion
|
||||||
|
versionCode flutterVersionCode.toInteger()
|
||||||
|
versionName flutterVersionName
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
// TODO: Add your own signing config for the release build.
|
||||||
|
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||||
|
signingConfig signingConfigs.debug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flutter {
|
||||||
|
source '../..'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.pedidosapp.pedidos_app">
|
||||||
|
<!-- Flutter needs it to communicate with the running application
|
||||||
|
to allow setting breakpoints, to provide hot reload, etc.
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.sigmac.agenteventas">
|
||||||
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
|
<uses-feature android:name="android.hardware.camera" android:required="false"/>
|
||||||
|
<application
|
||||||
|
android:label="Agente Ventas"
|
||||||
|
android:name="${applicationName}"
|
||||||
|
android:icon="@mipmap/ic_launcher">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:launchMode="singleTop"
|
||||||
|
android:theme="@style/LaunchTheme"
|
||||||
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
|
android:hardwareAccelerated="true"
|
||||||
|
android:windowSoftInputMode="adjustResize">
|
||||||
|
<!-- Specifies an Android theme to apply to this Activity as soon as
|
||||||
|
the Android process has started. This theme is visible to the user
|
||||||
|
while the Flutter UI initializes. After that, this theme continues
|
||||||
|
to determine the Window background behind the Flutter UI. -->
|
||||||
|
<meta-data
|
||||||
|
android:name="io.flutter.embedding.android.NormalTheme"
|
||||||
|
android:resource="@style/NormalTheme"
|
||||||
|
/>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<!-- Don't delete the meta-data below.
|
||||||
|
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||||
|
<meta-data
|
||||||
|
android:name="flutterEmbedding"
|
||||||
|
android:value="2" />
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.sigmac.agenteventas
|
||||||
|
|
||||||
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
|
class MainActivity: FlutterActivity() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Modify this file to customize your launch splash screen -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="?android:colorBackground" />
|
||||||
|
|
||||||
|
<!-- You can insert your own image assets here -->
|
||||||
|
<!-- <item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@mipmap/launch_image" />
|
||||||
|
</item> -->
|
||||||
|
</layer-list>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Modify this file to customize your launch splash screen -->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@android:color/white" />
|
||||||
|
|
||||||
|
<!-- You can insert your own image assets here -->
|
||||||
|
<!-- <item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@mipmap/launch_image" />
|
||||||
|
</item> -->
|
||||||
|
</layer-list>
|
||||||
|
After Width: | Height: | Size: 544 B |
|
After Width: | Height: | Size: 442 B |
|
After Width: | Height: | Size: 721 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
|
||||||
|
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<!-- Show a splash screen on the activity. Automatically removed when
|
||||||
|
Flutter draws its first frame -->
|
||||||
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
|
</style>
|
||||||
|
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||||
|
This theme determines the color of the Android Window while your
|
||||||
|
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||||
|
running.
|
||||||
|
|
||||||
|
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||||
|
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
|
||||||
|
<item name="android:windowBackground">?android:colorBackground</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
|
||||||
|
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
|
<!-- Show a splash screen on the activity. Automatically removed when
|
||||||
|
Flutter draws its first frame -->
|
||||||
|
<item name="android:windowBackground">@drawable/launch_background</item>
|
||||||
|
</style>
|
||||||
|
<!-- Theme applied to the Android Window as soon as the process has started.
|
||||||
|
This theme determines the color of the Android Window while your
|
||||||
|
Flutter UI initializes, as well as behind your Flutter UI while its
|
||||||
|
running.
|
||||||
|
|
||||||
|
This Theme is only used starting with V2 of Flutter's Android embedding. -->
|
||||||
|
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
|
||||||
|
<item name="android:windowBackground">?android:colorBackground</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.pedidosapp.pedidos_app">
|
||||||
|
<!-- Flutter needs it to communicate with the running application
|
||||||
|
to allow setting breakpoints, to provide hot reload, etc.
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.6.10'
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.buildDir = '../build'
|
||||||
|
subprojects {
|
||||||
|
project.buildDir = "${rootProject.buildDir}/${project.name}"
|
||||||
|
}
|
||||||
|
subprojects {
|
||||||
|
project.evaluationDependsOn(':app')
|
||||||
|
}
|
||||||
|
|
||||||
|
task clean(type: Delete) {
|
||||||
|
delete rootProject.buildDir
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
android.useAndroidX=true
|
||||||
|
android.enableJetifier=true
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#Fri Jun 23 08:50:38 CEST 2017
|
||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
include ':app'
|
||||||
|
|
||||||
|
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
|
||||||
|
def properties = new Properties()
|
||||||
|
|
||||||
|
assert localPropertiesFile.exists()
|
||||||
|
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
|
||||||
|
|
||||||
|
def flutterSdkPath = properties.getProperty("flutter.sdk")
|
||||||
|
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
|
||||||
|
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
|
||||||
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,30 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
|
||||||
|
|
||||||
|
<!-- Fondo redondeado azul -->
|
||||||
|
<rect width="512" height="512" rx="112" fill="#1E40AF"/>
|
||||||
|
|
||||||
|
<!-- Sombra suave de la ruta (halo) -->
|
||||||
|
<path d="M 88 424 C 88 290 228 304 228 178 C 228 90 358 60 424 88"
|
||||||
|
stroke="rgba(255,255,255,0.15)" stroke-width="60"
|
||||||
|
fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
|
||||||
|
<!-- Línea de ruta (blanca) -->
|
||||||
|
<path d="M 88 424 C 88 290 228 304 228 178 C 228 90 358 60 424 88"
|
||||||
|
stroke="white" stroke-width="30"
|
||||||
|
fill="none" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
|
||||||
|
<!-- Parada 1 — inicio (círculo hueco blanco) -->
|
||||||
|
<circle cx="88" cy="424" r="42" fill="#1E40AF" stroke="white" stroke-width="18"/>
|
||||||
|
|
||||||
|
<!-- Parada 2 — intermedia (círculo hueco blanco) -->
|
||||||
|
<circle cx="228" cy="178" r="42" fill="#1E40AF" stroke="white" stroke-width="18"/>
|
||||||
|
|
||||||
|
<!-- Parada 3 — destino (pin naranja) -->
|
||||||
|
<!-- Cuerpo del pin -->
|
||||||
|
<circle cx="424" cy="88" r="56" fill="#F97316"/>
|
||||||
|
<!-- Punta del pin -->
|
||||||
|
<path d="M 396 124 Q 424 172 452 124 Z" fill="#F97316"/>
|
||||||
|
<!-- Punto interior blanco -->
|
||||||
|
<circle cx="424" cy="82" r="24" fill="white"/>
|
||||||
|
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,34 @@
|
|||||||
|
**/dgph
|
||||||
|
*.mode1v3
|
||||||
|
*.mode2v3
|
||||||
|
*.moved-aside
|
||||||
|
*.pbxuser
|
||||||
|
*.perspectivev3
|
||||||
|
**/*sync/
|
||||||
|
.sconsign.dblite
|
||||||
|
.tags*
|
||||||
|
**/.vagrant/
|
||||||
|
**/DerivedData/
|
||||||
|
Icon?
|
||||||
|
**/Pods/
|
||||||
|
**/.symlinks/
|
||||||
|
profile
|
||||||
|
xcuserdata
|
||||||
|
**/.generated/
|
||||||
|
Flutter/App.framework
|
||||||
|
Flutter/Flutter.framework
|
||||||
|
Flutter/Flutter.podspec
|
||||||
|
Flutter/Generated.xcconfig
|
||||||
|
Flutter/ephemeral/
|
||||||
|
Flutter/app.flx
|
||||||
|
Flutter/app.zip
|
||||||
|
Flutter/flutter_assets/
|
||||||
|
Flutter/flutter_export_environment.sh
|
||||||
|
ServiceDefinitions.json
|
||||||
|
Runner/GeneratedPluginRegistrant.*
|
||||||
|
|
||||||
|
# Exceptions to above rules.
|
||||||
|
!default.mode1v3
|
||||||
|
!default.mode2v3
|
||||||
|
!default.pbxuser
|
||||||
|
!default.perspectivev3
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>App</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>io.flutter.flutter.app</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>App</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>FMWK</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>MinimumOSVersion</key>
|
||||||
|
<string>9.0</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include "Generated.xcconfig"
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#include "Generated.xcconfig"
|
||||||
@@ -0,0 +1,481 @@
|
|||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 50;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXBuildFile section */
|
||||||
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||||
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||||
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||||
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||||
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||||
|
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||||
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
|
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
|
||||||
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
dstPath = "";
|
||||||
|
dstSubfolderSpec = 10;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
name = "Embed Frameworks";
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||||
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||||
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||||
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||||
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
|
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||||
|
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||||
|
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||||
|
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||||
|
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
|
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
97C146EB1CF9000F007C117D /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||||
|
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||||
|
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||||
|
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||||
|
);
|
||||||
|
name = Flutter;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146E51CF9000F007C117D = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9740EEB11CF90186004384FC /* Flutter */,
|
||||||
|
97C146F01CF9000F007C117D /* Runner */,
|
||||||
|
97C146EF1CF9000F007C117D /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146EF1CF9000F007C117D /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
97C146EE1CF9000F007C117D /* Runner.app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146F01CF9000F007C117D /* Runner */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
97C146FA1CF9000F007C117D /* Main.storyboard */,
|
||||||
|
97C146FD1CF9000F007C117D /* Assets.xcassets */,
|
||||||
|
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
|
||||||
|
97C147021CF9000F007C117D /* Info.plist */,
|
||||||
|
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
|
||||||
|
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
|
||||||
|
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
|
||||||
|
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
|
||||||
|
);
|
||||||
|
path = Runner;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
97C146ED1CF9000F007C117D /* Runner */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
|
||||||
|
buildPhases = (
|
||||||
|
9740EEB61CF901F6004384FC /* Run Script */,
|
||||||
|
97C146EA1CF9000F007C117D /* Sources */,
|
||||||
|
97C146EB1CF9000F007C117D /* Frameworks */,
|
||||||
|
97C146EC1CF9000F007C117D /* Resources */,
|
||||||
|
9705A1C41CF9048500538489 /* Embed Frameworks */,
|
||||||
|
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = Runner;
|
||||||
|
productName = Runner;
|
||||||
|
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
|
||||||
|
productType = "com.apple.product-type.application";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
97C146E61CF9000F007C117D /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 1300;
|
||||||
|
ORGANIZATIONNAME = "";
|
||||||
|
TargetAttributes = {
|
||||||
|
97C146ED1CF9000F007C117D = {
|
||||||
|
CreatedOnToolsVersion = 7.3.1;
|
||||||
|
LastSwiftMigration = 1100;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
|
||||||
|
compatibilityVersion = "Xcode 9.3";
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 97C146E51CF9000F007C117D;
|
||||||
|
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
97C146ED1CF9000F007C117D /* Runner */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXResourcesBuildPhase section */
|
||||||
|
97C146EC1CF9000F007C117D /* Resources */ = {
|
||||||
|
isa = PBXResourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
|
||||||
|
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
|
||||||
|
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
|
||||||
|
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
|
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "Thin Binary";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||||
|
};
|
||||||
|
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||||
|
isa = PBXShellScriptBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
inputPaths = (
|
||||||
|
);
|
||||||
|
name = "Run Script";
|
||||||
|
outputPaths = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
shellPath = /bin/sh;
|
||||||
|
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
|
||||||
|
};
|
||||||
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
97C146EA1CF9000F007C117D /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
|
||||||
|
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXVariantGroup section */
|
||||||
|
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
97C146FB1CF9000F007C117D /* Base */,
|
||||||
|
);
|
||||||
|
name = Main.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
97C147001CF9000F007C117D /* Base */,
|
||||||
|
);
|
||||||
|
name = LaunchScreen.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXVariantGroup section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
249021D3217E4FDB00AE95B9 /* Profile */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SUPPORTED_PLATFORMS = iphoneos;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Profile;
|
||||||
|
};
|
||||||
|
249021D4217E4FDB00AE95B9 /* Profile */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
|
ENABLE_BITCODE = NO;
|
||||||
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.pedidosapp.pedidosApp;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
};
|
||||||
|
name = Profile;
|
||||||
|
};
|
||||||
|
97C147031CF9000F007C117D /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
97C147041CF9000F007C117D /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
SDKROOT = iphoneos;
|
||||||
|
SUPPORTED_PLATFORMS = iphoneos;
|
||||||
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
VALIDATE_PRODUCT = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
97C147061CF9000F007C117D /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
|
ENABLE_BITCODE = NO;
|
||||||
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.pedidosapp.pedidosApp;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
97C147071CF9000F007C117D /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||||
|
buildSettings = {
|
||||||
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
|
ENABLE_BITCODE = NO;
|
||||||
|
INFOPLIST_FILE = Runner/Info.plist;
|
||||||
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
|
"$(inherited)",
|
||||||
|
"@executable_path/Frameworks",
|
||||||
|
);
|
||||||
|
PRODUCT_BUNDLE_IDENTIFIER = com.pedidosapp.pedidosApp;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
|
SWIFT_VERSION = 5.0;
|
||||||
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
97C147031CF9000F007C117D /* Debug */,
|
||||||
|
97C147041CF9000F007C117D /* Release */,
|
||||||
|
249021D3217E4FDB00AE95B9 /* Profile */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
97C147061CF9000F007C117D /* Debug */,
|
||||||
|
97C147071CF9000F007C117D /* Release */,
|
||||||
|
249021D4217E4FDB00AE95B9 /* Profile */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 97C146E61CF9000F007C117D /* Project object */;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>PreviewsEnabled</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Scheme
|
||||||
|
LastUpgradeVersion = "1300"
|
||||||
|
version = "1.3">
|
||||||
|
<BuildAction
|
||||||
|
parallelizeBuildables = "YES"
|
||||||
|
buildImplicitDependencies = "YES">
|
||||||
|
<BuildActionEntries>
|
||||||
|
<BuildActionEntry
|
||||||
|
buildForTesting = "YES"
|
||||||
|
buildForRunning = "YES"
|
||||||
|
buildForProfiling = "YES"
|
||||||
|
buildForArchiving = "YES"
|
||||||
|
buildForAnalyzing = "YES">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||||
|
BuildableName = "Runner.app"
|
||||||
|
BlueprintName = "Runner"
|
||||||
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildActionEntry>
|
||||||
|
</BuildActionEntries>
|
||||||
|
</BuildAction>
|
||||||
|
<TestAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||||
|
<MacroExpansion>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||||
|
BuildableName = "Runner.app"
|
||||||
|
BlueprintName = "Runner"
|
||||||
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</MacroExpansion>
|
||||||
|
<Testables>
|
||||||
|
</Testables>
|
||||||
|
</TestAction>
|
||||||
|
<LaunchAction
|
||||||
|
buildConfiguration = "Debug"
|
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||||
|
launchStyle = "0"
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
debugDocumentVersioning = "YES"
|
||||||
|
debugServiceExtension = "internal"
|
||||||
|
allowLocationSimulation = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||||
|
BuildableName = "Runner.app"
|
||||||
|
BlueprintName = "Runner"
|
||||||
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</LaunchAction>
|
||||||
|
<ProfileAction
|
||||||
|
buildConfiguration = "Profile"
|
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||||
|
savedToolIdentifier = ""
|
||||||
|
useCustomWorkingDirectory = "NO"
|
||||||
|
debugDocumentVersioning = "YES">
|
||||||
|
<BuildableProductRunnable
|
||||||
|
runnableDebuggingMode = "0">
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||||
|
BuildableName = "Runner.app"
|
||||||
|
BlueprintName = "Runner"
|
||||||
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</BuildableProductRunnable>
|
||||||
|
</ProfileAction>
|
||||||
|
<AnalyzeAction
|
||||||
|
buildConfiguration = "Debug">
|
||||||
|
</AnalyzeAction>
|
||||||
|
<ArchiveAction
|
||||||
|
buildConfiguration = "Release"
|
||||||
|
revealArchiveInOrganizer = "YES">
|
||||||
|
</ArchiveAction>
|
||||||
|
</Scheme>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "group:Runner.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>PreviewsEnabled</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import UIKit
|
||||||
|
import Flutter
|
||||||
|
|
||||||
|
@UIApplicationMain
|
||||||
|
@objc class AppDelegate: FlutterAppDelegate {
|
||||||
|
override func application(
|
||||||
|
_ application: UIApplication,
|
||||||
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||||
|
) -> Bool {
|
||||||
|
GeneratedPluginRegistrant.register(with: self)
|
||||||
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-20x20@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-20x20@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-40x40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-40x40@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-60x60@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-60x60@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-20x20@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-20x20@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-29x29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-40x40@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-40x40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-76x76@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-76x76@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "83.5x83.5",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-83.5x83.5@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "1024x1024",
|
||||||
|
"idiom" : "ios-marketing",
|
||||||
|
"filename" : "Icon-App-1024x1024@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 564 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "LaunchImage.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "LaunchImage@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "LaunchImage@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 68 B |
|
After Width: | Height: | Size: 68 B |
|
After Width: | Height: | Size: 68 B |
@@ -0,0 +1,5 @@
|
|||||||
|
# Launch Screen Assets
|
||||||
|
|
||||||
|
You can customize the launch screen with your own desired assets by replacing the image files in this directory.
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||||
|
<dependencies>
|
||||||
|
<deployment identifier="iOS"/>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="EHf-IW-A2E">
|
||||||
|
<objects>
|
||||||
|
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||||
|
<layoutGuides>
|
||||||
|
<viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/>
|
||||||
|
<viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/>
|
||||||
|
</layoutGuides>
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4">
|
||||||
|
</imageView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/>
|
||||||
|
<constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="53" y="375"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
<resources>
|
||||||
|
<image name="LaunchImage" width="168" height="185"/>
|
||||||
|
</resources>
|
||||||
|
</document>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
|
||||||
|
<dependencies>
|
||||||
|
<deployment identifier="iOS"/>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--Flutter View Controller-->
|
||||||
|
<scene sceneID="tne-QT-ifu">
|
||||||
|
<objects>
|
||||||
|
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
|
||||||
|
<layoutGuides>
|
||||||
|
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
|
||||||
|
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
|
||||||
|
</layoutGuides>
|
||||||
|
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Agente Ventas</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>Agente Ventas SIGMAC</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>$(FLUTTER_BUILD_NAME)</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
<key>UIMainStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
|
<false/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#import "GeneratedPluginRegistrant.h"
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'providers/app_provider.dart';
|
||||||
|
import 'theme/app_theme.dart';
|
||||||
|
import 'screens/login/login_screen.dart';
|
||||||
|
import 'screens/main_shell.dart';
|
||||||
|
|
||||||
|
class PedidosApp extends StatelessWidget {
|
||||||
|
final GlobalKey<NavigatorState> navigatorKey;
|
||||||
|
|
||||||
|
const PedidosApp({Key? key, required this.navigatorKey}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MaterialApp(
|
||||||
|
title: 'Agente Ventas SIGMAC',
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
theme: AppTheme.light,
|
||||||
|
navigatorKey: navigatorKey,
|
||||||
|
home: Consumer<AppProvider>(
|
||||||
|
builder: (_, provider, __) {
|
||||||
|
if (provider.loading) return const _LoadingScreen();
|
||||||
|
return provider.isLoggedIn ? const MainShell() : const LoginScreen();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoadingScreen extends StatelessWidget {
|
||||||
|
const _LoadingScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.primaryColor,
|
||||||
|
body: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(22),
|
||||||
|
child: Image.asset('assets/icon/icon.png', width: 80, height: 80),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
const Text(
|
||||||
|
'Agente Ventas',
|
||||||
|
style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: Colors.white),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
'by SIGMAC',
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.6), letterSpacing: 2.0),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
const Text('Cargando datos...', style: TextStyle(color: Colors.white70, fontSize: 13)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,462 @@
|
|||||||
|
import '../models/vendedor.dart';
|
||||||
|
import '../models/cliente.dart';
|
||||||
|
import '../models/producto.dart';
|
||||||
|
import '../models/pedido.dart';
|
||||||
|
import '../models/item_pedido.dart';
|
||||||
|
import '../models/parada_ruta.dart';
|
||||||
|
import '../models/ruta.dart';
|
||||||
|
|
||||||
|
class MockData {
|
||||||
|
// ── Vendedor ──────────────────────────────────────────────────
|
||||||
|
static const vendedor = Vendedor(
|
||||||
|
id: 'v1',
|
||||||
|
nombre: 'Roberto Vargas',
|
||||||
|
email: 'admin@telcotronics.com',
|
||||||
|
telefono: '+591 76123456',
|
||||||
|
zona: 'La Paz – Centro y Zona Sur',
|
||||||
|
avatarInitials: 'RV',
|
||||||
|
);
|
||||||
|
|
||||||
|
// ── Clientes ──────────────────────────────────────────────────
|
||||||
|
static final clientes = [
|
||||||
|
const Cliente(
|
||||||
|
id: 'c1',
|
||||||
|
nombre: 'TechZone Bolivia',
|
||||||
|
razonSocial: 'TechZone Bolivia S.R.L.',
|
||||||
|
direccion: 'Av. 16 de Julio 1890, El Prado, La Paz',
|
||||||
|
telefono: '+591 22310456',
|
||||||
|
nit: '1023456789',
|
||||||
|
lat: -16.495,
|
||||||
|
lng: -68.133,
|
||||||
|
categoria: 'Mayorista',
|
||||||
|
),
|
||||||
|
const Cliente(
|
||||||
|
id: 'c2',
|
||||||
|
nombre: 'InfoSystems La Paz',
|
||||||
|
razonSocial: 'InfoSystems Bolivia S.A.',
|
||||||
|
direccion: 'Calle Comercio 1245, Piso 3, La Paz',
|
||||||
|
telefono: '+591 22451230',
|
||||||
|
nit: '2034567891',
|
||||||
|
lat: -16.498,
|
||||||
|
lng: -68.130,
|
||||||
|
categoria: 'Distribuidor',
|
||||||
|
),
|
||||||
|
const Cliente(
|
||||||
|
id: 'c3',
|
||||||
|
nombre: 'CyberShop Sopocachi',
|
||||||
|
razonSocial: 'Miguel Ángel Ramos',
|
||||||
|
direccion: 'Av. 6 de Agosto 2378, Sopocachi',
|
||||||
|
telefono: '+591 71234890',
|
||||||
|
nit: '3045678912',
|
||||||
|
lat: -16.507,
|
||||||
|
lng: -68.121,
|
||||||
|
categoria: 'Minorista',
|
||||||
|
),
|
||||||
|
const Cliente(
|
||||||
|
id: 'c4',
|
||||||
|
nombre: 'Hotel Presidente La Paz',
|
||||||
|
razonSocial: 'Hoteles Presidente Bolivia S.A.',
|
||||||
|
direccion: 'Calle Potosí 920, Centro, La Paz',
|
||||||
|
telefono: '+591 22406666',
|
||||||
|
nit: '4056789123',
|
||||||
|
lat: -16.500,
|
||||||
|
lng: -68.128,
|
||||||
|
categoria: 'Empresa',
|
||||||
|
),
|
||||||
|
const Cliente(
|
||||||
|
id: 'c5',
|
||||||
|
nombre: 'Colegio Técnico INFOCAL',
|
||||||
|
razonSocial: 'INFOCAL La Paz',
|
||||||
|
direccion: 'Av. Arce 2081, Miraflores, La Paz',
|
||||||
|
telefono: '+591 22430012',
|
||||||
|
nit: '5067891234',
|
||||||
|
lat: -16.514,
|
||||||
|
lng: -68.115,
|
||||||
|
categoria: 'Institución',
|
||||||
|
),
|
||||||
|
const Cliente(
|
||||||
|
id: 'c6',
|
||||||
|
nombre: 'DataCenter Andino',
|
||||||
|
razonSocial: 'Andino Cloud Solutions S.R.L.',
|
||||||
|
direccion: 'Av. Hernando Siles 5635, Obrajes',
|
||||||
|
telefono: '+591 22782200',
|
||||||
|
nit: '6078912345',
|
||||||
|
lat: -16.521,
|
||||||
|
lng: -68.118,
|
||||||
|
categoria: 'Empresa',
|
||||||
|
),
|
||||||
|
const Cliente(
|
||||||
|
id: 'c7',
|
||||||
|
nombre: 'Electrónica Calacoto',
|
||||||
|
razonSocial: 'Electrónica Calacoto S.R.L.',
|
||||||
|
direccion: 'Calle 21 de Calacoto 8251, Zona Sur',
|
||||||
|
telefono: '+591 22771890',
|
||||||
|
nit: '7089123456',
|
||||||
|
lat: -16.531,
|
||||||
|
lng: -68.107,
|
||||||
|
categoria: 'Minorista',
|
||||||
|
),
|
||||||
|
const Cliente(
|
||||||
|
id: 'c8',
|
||||||
|
nombre: 'Gobernación Dpto. La Paz',
|
||||||
|
razonSocial: 'Gobernación del Departamento de La Paz',
|
||||||
|
direccion: 'Av. Mariscal Santa Cruz, Edif. Gobernación',
|
||||||
|
telefono: '+591 22204500',
|
||||||
|
nit: '1000000001',
|
||||||
|
lat: -16.501,
|
||||||
|
lng: -68.134,
|
||||||
|
categoria: 'Gobierno',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
// ── Productos ─────────────────────────────────────────────────
|
||||||
|
static final productos = [
|
||||||
|
// Redes & Conectividad
|
||||||
|
const Producto(
|
||||||
|
id: 'p01', sku: 'RED001',
|
||||||
|
nombre: 'Router WiFi TP-Link Archer AX73',
|
||||||
|
descripcion: 'Router AX5400 Wi-Fi 6, doble banda, 6 antenas, ideal oficinas y hogares',
|
||||||
|
categoria: 'Redes & Conectividad',
|
||||||
|
precio: 1250.00, precioMayorista: 1080.00,
|
||||||
|
unidad: 'unidad', stock: 24, emoji: '📡',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p02', sku: 'RED002',
|
||||||
|
nombre: 'Switch Cisco SG350 24 puertos',
|
||||||
|
descripcion: 'Switch gestionable 24 puertos Gigabit, ideal redes empresariales',
|
||||||
|
categoria: 'Redes & Conectividad',
|
||||||
|
precio: 4800.00, precioMayorista: 4200.00,
|
||||||
|
unidad: 'unidad', stock: 8, emoji: '🔀',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p03', sku: 'RED003',
|
||||||
|
nombre: 'Access Point Ubiquiti UniFi U6 Pro',
|
||||||
|
descripcion: 'AP Wi-Fi 6 de alto rendimiento, cobertura hasta 300m², PoE',
|
||||||
|
categoria: 'Redes & Conectividad',
|
||||||
|
precio: 2100.00, precioMayorista: 1820.00,
|
||||||
|
unidad: 'unidad', stock: 15, emoji: '📶',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p04', sku: 'RED004',
|
||||||
|
nombre: 'Cable UTP Cat6 Rollo 305m',
|
||||||
|
descripcion: 'Cable de red categoría 6, 305 metros, color gris, certificado',
|
||||||
|
categoria: 'Redes & Conectividad',
|
||||||
|
precio: 680.00, precioMayorista: 580.00,
|
||||||
|
unidad: 'rollo', stock: 30, emoji: '🔌',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p05', sku: 'RED005',
|
||||||
|
nombre: 'Patch Panel 24p Cat6 AMP',
|
||||||
|
descripcion: 'Panel de parcheo 24 puertos, categoría 6, montaje en rack 1U',
|
||||||
|
categoria: 'Redes & Conectividad',
|
||||||
|
precio: 540.00, precioMayorista: 460.00,
|
||||||
|
unidad: 'unidad', stock: 12, emoji: '🗄️',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p06', sku: 'RED006',
|
||||||
|
nombre: 'Firewall Fortinet FortiGate 60F',
|
||||||
|
descripcion: 'Firewall NGFW 10 Gbps, VPN, protección avanzada de amenazas',
|
||||||
|
categoria: 'Redes & Conectividad',
|
||||||
|
precio: 8900.00, precioMayorista: 7800.00,
|
||||||
|
unidad: 'unidad', stock: 5, emoji: '🛡️',
|
||||||
|
),
|
||||||
|
|
||||||
|
// Telefonía & Móviles
|
||||||
|
const Producto(
|
||||||
|
id: 'p07', sku: 'TEL001',
|
||||||
|
nombre: 'Smartphone Samsung Galaxy A55 5G',
|
||||||
|
descripcion: '6.6" AMOLED, 8GB RAM, 256GB, cámara 50MP, 5G, batería 5000mAh',
|
||||||
|
categoria: 'Telefonía & Móviles',
|
||||||
|
precio: 3200.00, precioMayorista: 2850.00,
|
||||||
|
unidad: 'unidad', stock: 20, emoji: '📱',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p08', sku: 'TEL002',
|
||||||
|
nombre: 'Tablet Lenovo Tab M11 LTE',
|
||||||
|
descripcion: '11" FHD, 4GB RAM, 128GB, Android 13, SIM 4G, lápiz incluido',
|
||||||
|
categoria: 'Telefonía & Móviles',
|
||||||
|
precio: 2400.00, precioMayorista: 2100.00,
|
||||||
|
unidad: 'unidad', stock: 12, emoji: '📟',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p09', sku: 'TEL003',
|
||||||
|
nombre: 'Teléfono IP Yealink T46U',
|
||||||
|
descripcion: 'Teléfono VoIP color, 16 líneas SIP, USB, PoE, pantalla 4.3"',
|
||||||
|
categoria: 'Telefonía & Móviles',
|
||||||
|
precio: 1450.00, precioMayorista: 1240.00,
|
||||||
|
unidad: 'unidad', stock: 18, emoji: '☎️',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p10', sku: 'TEL004',
|
||||||
|
nombre: 'Central IP 3CX Licencia 25 ext.',
|
||||||
|
descripcion: 'Licencia anual central telefónica IP 3CX, hasta 25 extensiones',
|
||||||
|
categoria: 'Telefonía & Móviles',
|
||||||
|
precio: 5600.00, precioMayorista: 4900.00,
|
||||||
|
unidad: 'licencia', stock: 10, emoji: '🏢',
|
||||||
|
),
|
||||||
|
|
||||||
|
// Cómputo & Periféricos
|
||||||
|
const Producto(
|
||||||
|
id: 'p11', sku: 'COM001',
|
||||||
|
nombre: 'Laptop HP ProBook 450 G10',
|
||||||
|
descripcion: 'Intel Core i7-13ª gen, 16GB RAM, SSD 512GB, 15.6" FHD, Windows 11 Pro',
|
||||||
|
categoria: 'Cómputo & Periféricos',
|
||||||
|
precio: 9800.00, precioMayorista: 8700.00,
|
||||||
|
unidad: 'unidad', stock: 10, emoji: '💻',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p12', sku: 'COM002',
|
||||||
|
nombre: 'Monitor LG 27" 4K UHD IPS',
|
||||||
|
descripcion: 'Monitor 27 pulgadas 4K, panel IPS, USB-C, HDR10, 60Hz',
|
||||||
|
categoria: 'Cómputo & Periféricos',
|
||||||
|
precio: 3600.00, precioMayorista: 3100.00,
|
||||||
|
unidad: 'unidad', stock: 14, emoji: '🖥️',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p13', sku: 'COM003',
|
||||||
|
nombre: 'UPS APC 1500VA Smart',
|
||||||
|
descripcion: 'UPS línea interactiva 1500VA/900W, 8 tomas, pantalla LCD, USB',
|
||||||
|
categoria: 'Cómputo & Periféricos',
|
||||||
|
precio: 2200.00, precioMayorista: 1900.00,
|
||||||
|
unidad: 'unidad', stock: 16, emoji: '🔋',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p14', sku: 'COM004',
|
||||||
|
nombre: 'Impresora HP LaserJet Pro M404n',
|
||||||
|
descripcion: 'Impresora láser monocromática, 38ppm, red Ethernet, duplex automático',
|
||||||
|
categoria: 'Cómputo & Periféricos',
|
||||||
|
precio: 3100.00, precioMayorista: 2700.00,
|
||||||
|
unidad: 'unidad', stock: 9, emoji: '🖨️',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p15', sku: 'COM005',
|
||||||
|
nombre: 'Disco Duro Externo Seagate 2TB',
|
||||||
|
descripcion: 'HDD externo 2TB USB 3.0, compatible Windows/Mac/Linux',
|
||||||
|
categoria: 'Cómputo & Periféricos',
|
||||||
|
precio: 580.00, precioMayorista: 490.00,
|
||||||
|
unidad: 'unidad', stock: 35, emoji: '💾',
|
||||||
|
),
|
||||||
|
|
||||||
|
// Seguridad & Vigilancia
|
||||||
|
const Producto(
|
||||||
|
id: 'p16', sku: 'SEG001',
|
||||||
|
nombre: 'Cámara IP Hikvision 4MP Domo',
|
||||||
|
descripcion: 'Cámara IP domo 4MP, IR 30m, PoE, IP67, detección de movimiento IA',
|
||||||
|
categoria: 'Seguridad & Vigilancia',
|
||||||
|
precio: 980.00, precioMayorista: 840.00,
|
||||||
|
unidad: 'unidad', stock: 28, emoji: '📷',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p17', sku: 'SEG002',
|
||||||
|
nombre: 'NVR Dahua 16 canales 4K',
|
||||||
|
descripcion: 'Grabador de red 16 canales, resolución 4K, HDMI, 2 bahías HDD, PoE',
|
||||||
|
categoria: 'Seguridad & Vigilancia',
|
||||||
|
precio: 2800.00, precioMayorista: 2400.00,
|
||||||
|
unidad: 'unidad', stock: 7, emoji: '🎥',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p18', sku: 'SEG003',
|
||||||
|
nombre: 'Control de Acceso ZKTeco SF300',
|
||||||
|
descripcion: 'Control de acceso biométrico facial y huella, 3000 usuarios, TCP/IP',
|
||||||
|
categoria: 'Seguridad & Vigilancia',
|
||||||
|
precio: 1680.00, precioMayorista: 1450.00,
|
||||||
|
unidad: 'unidad', stock: 11, emoji: '🔒',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p19', sku: 'SEG004',
|
||||||
|
nombre: 'Disco Duro WD Purple 4TB Surveillance',
|
||||||
|
descripcion: 'HDD diseñado para videovigilancia, funcionamiento 24/7, SATA 3',
|
||||||
|
categoria: 'Seguridad & Vigilancia',
|
||||||
|
precio: 760.00, precioMayorista: 650.00,
|
||||||
|
unidad: 'unidad', stock: 22, emoji: '🗂️',
|
||||||
|
),
|
||||||
|
|
||||||
|
// Servicios Telcotronics
|
||||||
|
const Producto(
|
||||||
|
id: 'p20', sku: 'SRV001',
|
||||||
|
nombre: 'Instalación de Red Estructurada',
|
||||||
|
descripcion: 'Servicio de instalación y certificación de red categoría 6 por punto',
|
||||||
|
categoria: 'Servicios',
|
||||||
|
precio: 350.00, precioMayorista: 300.00,
|
||||||
|
unidad: 'punto', stock: 999, emoji: '🔧',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p21', sku: 'SRV002',
|
||||||
|
nombre: 'Soporte Técnico Presencial (hora)',
|
||||||
|
descripcion: 'Visita técnica presencial, diagnóstico y resolución de problemas',
|
||||||
|
categoria: 'Servicios',
|
||||||
|
precio: 280.00, precioMayorista: 240.00,
|
||||||
|
unidad: 'hora', stock: 999, emoji: '🛠️',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p22', sku: 'SRV003',
|
||||||
|
nombre: 'Contrato Mantenimiento Anual Redes',
|
||||||
|
descripcion: 'Mantenimiento preventivo trimestral de infraestructura de red',
|
||||||
|
categoria: 'Servicios',
|
||||||
|
precio: 4200.00, precioMayorista: 3600.00,
|
||||||
|
unidad: 'contrato', stock: 999, emoji: '📋',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p23', sku: 'SRV004',
|
||||||
|
nombre: 'Configuración Firewall / VPN',
|
||||||
|
descripcion: 'Servicio de configuración, políticas de seguridad y túneles VPN',
|
||||||
|
categoria: 'Servicios',
|
||||||
|
precio: 1200.00, precioMayorista: 1000.00,
|
||||||
|
unidad: 'servicio', stock: 999, emoji: '⚙️',
|
||||||
|
),
|
||||||
|
const Producto(
|
||||||
|
id: 'p24', sku: 'SRV005',
|
||||||
|
nombre: 'Instalación CCTV (cámara)',
|
||||||
|
descripcion: 'Instalación y configuración de cámara IP incluye cableado hasta 30m',
|
||||||
|
categoria: 'Servicios',
|
||||||
|
precio: 420.00, precioMayorista: 360.00,
|
||||||
|
unidad: 'cámara', stock: 999, emoji: '📹',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
// ── Ruta del día ──────────────────────────────────────────────
|
||||||
|
static List<ParadaRuta> _buildParadas() {
|
||||||
|
return [
|
||||||
|
ParadaRuta(
|
||||||
|
id: 'pr1', cliente: clientes[0], orden: 1,
|
||||||
|
estado: EstadoParada.visitado, horaEstimada: '08:30', horaVisita: '08:42',
|
||||||
|
notasVisita: 'Firmó pedido. Solicita cotización para 10 AP adicionales.',
|
||||||
|
),
|
||||||
|
ParadaRuta(
|
||||||
|
id: 'pr2', cliente: clientes[2], orden: 2,
|
||||||
|
estado: EstadoParada.visitado, horaEstimada: '09:30', horaVisita: '09:28',
|
||||||
|
),
|
||||||
|
ParadaRuta(
|
||||||
|
id: 'pr3', cliente: clientes[3], orden: 3,
|
||||||
|
estado: EstadoParada.pendiente, horaEstimada: '10:45',
|
||||||
|
),
|
||||||
|
ParadaRuta(
|
||||||
|
id: 'pr4', cliente: clientes[5], orden: 4,
|
||||||
|
estado: EstadoParada.pendiente, horaEstimada: '12:00',
|
||||||
|
),
|
||||||
|
ParadaRuta(
|
||||||
|
id: 'pr5', cliente: clientes[1], orden: 5,
|
||||||
|
estado: EstadoParada.pendiente, horaEstimada: '14:00',
|
||||||
|
),
|
||||||
|
ParadaRuta(
|
||||||
|
id: 'pr6', cliente: clientes[6], orden: 6,
|
||||||
|
estado: EstadoParada.pendiente, horaEstimada: '16:00',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
static Ruta buildRuta() => Ruta(
|
||||||
|
id: 'r1',
|
||||||
|
nombre: 'Ruta Centro & Zona Sur',
|
||||||
|
zona: 'Centro – Sopocachi – Miraflores – Obrajes – Calacoto',
|
||||||
|
paradas: _buildParadas(),
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// ── Pedidos ───────────────────────────────────────────────────
|
||||||
|
static List<Pedido> buildPedidos() {
|
||||||
|
final p = productos;
|
||||||
|
return [
|
||||||
|
// Pedido entregado hoy — TechZone
|
||||||
|
Pedido(
|
||||||
|
id: 'TTC-0041',
|
||||||
|
cliente: clientes[0],
|
||||||
|
estado: EstadoPedido.entregado,
|
||||||
|
fecha: DateTime.now().subtract(const Duration(hours: 3)),
|
||||||
|
notas: 'Entrega urgente. Factura a nombre de empresa.',
|
||||||
|
firmaBase64: 'signed',
|
||||||
|
items: [
|
||||||
|
ItemPedido(producto: p[0], cantidad: 5, precioUnitario: p[0].precioMayorista),
|
||||||
|
ItemPedido(producto: p[2], cantidad: 4, precioUnitario: p[2].precioMayorista),
|
||||||
|
ItemPedido(producto: p[3], cantidad: 3, precioUnitario: p[3].precioMayorista),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Pedido confirmado hoy — CyberShop
|
||||||
|
Pedido(
|
||||||
|
id: 'TTC-0042',
|
||||||
|
cliente: clientes[2],
|
||||||
|
estado: EstadoPedido.confirmado,
|
||||||
|
fecha: DateTime.now().subtract(const Duration(hours: 1)),
|
||||||
|
notas: 'Recoger en tienda',
|
||||||
|
firmaBase64: 'signed',
|
||||||
|
items: [
|
||||||
|
ItemPedido(producto: p[6], cantidad: 3, precioUnitario: p[6].precio),
|
||||||
|
ItemPedido(producto: p[14], cantidad: 4, precioUnitario: p[14].precio),
|
||||||
|
ItemPedido(producto: p[15], cantidad: 2, precioUnitario: p[15].precio),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Pedido pendiente — Hotel Presidente
|
||||||
|
Pedido(
|
||||||
|
id: 'TTC-0043',
|
||||||
|
cliente: clientes[3],
|
||||||
|
estado: EstadoPedido.pendiente,
|
||||||
|
fecha: DateTime.now().subtract(const Duration(days: 1)),
|
||||||
|
notas: 'Instalación CCTV piso 1 al 5. Coordinar con Jefe de Mantenimiento.',
|
||||||
|
items: [
|
||||||
|
ItemPedido(producto: p[15], cantidad: 12, precioUnitario: p[15].precioMayorista),
|
||||||
|
ItemPedido(producto: p[16], cantidad: 2, precioUnitario: p[16].precioMayorista),
|
||||||
|
ItemPedido(producto: p[18], cantidad: 1, precioUnitario: p[18].precioMayorista),
|
||||||
|
ItemPedido(producto: p[23], cantidad: 12, precioUnitario: p[23].precioMayorista),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Pedido pendiente — DataCenter Andino
|
||||||
|
Pedido(
|
||||||
|
id: 'TTC-0044',
|
||||||
|
cliente: clientes[5],
|
||||||
|
estado: EstadoPedido.pendiente,
|
||||||
|
fecha: DateTime.now().subtract(const Duration(days: 1, hours: 4)),
|
||||||
|
notas: 'Ampliar infraestructura sala de servidores. Requiere rack de 42U.',
|
||||||
|
items: [
|
||||||
|
ItemPedido(producto: p[1], cantidad: 2, precioUnitario: p[1].precioMayorista),
|
||||||
|
ItemPedido(producto: p[4], cantidad: 4, precioUnitario: p[4].precioMayorista),
|
||||||
|
ItemPedido(producto: p[5], cantidad: 1, precioUnitario: p[5].precioMayorista),
|
||||||
|
ItemPedido(producto: p[12], cantidad: 4, precioUnitario: p[12].precioMayorista),
|
||||||
|
ItemPedido(producto: p[21], cantidad: 8, precioUnitario: p[21].precioMayorista),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Pedido pendiente — InfoSystems
|
||||||
|
Pedido(
|
||||||
|
id: 'TTC-0045',
|
||||||
|
cliente: clientes[1],
|
||||||
|
estado: EstadoPedido.pendiente,
|
||||||
|
fecha: DateTime.now().subtract(const Duration(days: 2)),
|
||||||
|
notas: 'Pedido trimestral de reposición. Pago 30 días.',
|
||||||
|
items: [
|
||||||
|
ItemPedido(producto: p[0], cantidad: 10, precioUnitario: p[0].precioMayorista),
|
||||||
|
ItemPedido(producto: p[6], cantidad: 8, precioUnitario: p[6].precioMayorista),
|
||||||
|
ItemPedido(producto: p[8], cantidad: 6, precioUnitario: p[8].precioMayorista),
|
||||||
|
ItemPedido(producto: p[13], cantidad: 5, precioUnitario: p[13].precioMayorista),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Pedido confirmado — INFOCAL
|
||||||
|
Pedido(
|
||||||
|
id: 'TTC-0046',
|
||||||
|
cliente: clientes[4],
|
||||||
|
estado: EstadoPedido.confirmado,
|
||||||
|
fecha: DateTime.now().subtract(const Duration(days: 3)),
|
||||||
|
notas: 'Equipamiento laboratorio de redes. Licitación Ref. INFOCAL-2024-018.',
|
||||||
|
firmaBase64: 'signed',
|
||||||
|
items: [
|
||||||
|
ItemPedido(producto: p[1], cantidad: 1, precioUnitario: p[1].precioMayorista),
|
||||||
|
ItemPedido(producto: p[2], cantidad: 6, precioUnitario: p[2].precioMayorista),
|
||||||
|
ItemPedido(producto: p[3], cantidad: 5, precioUnitario: p[3].precioMayorista),
|
||||||
|
ItemPedido(producto: p[4], cantidad: 2, precioUnitario: p[4].precioMayorista),
|
||||||
|
ItemPedido(producto: p[20], cantidad: 48, precioUnitario: p[20].precioMayorista),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Pedido cancelado — Gobernación
|
||||||
|
Pedido(
|
||||||
|
id: 'TTC-0040',
|
||||||
|
cliente: clientes[7],
|
||||||
|
estado: EstadoPedido.cancelado,
|
||||||
|
fecha: DateTime.now().subtract(const Duration(days: 4)),
|
||||||
|
notas: 'Proceso licitatorio suspendido por cambio de presupuesto.',
|
||||||
|
items: [
|
||||||
|
ItemPedido(producto: p[10], cantidad: 20, precioUnitario: p[10].precioMayorista),
|
||||||
|
ItemPedido(producto: p[11], cantidad: 20, precioUnitario: p[11].precioMayorista),
|
||||||
|
ItemPedido(producto: p[22], cantidad: 1, precioUnitario: p[22].precioMayorista),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
import 'dart:io' show Platform;
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
import 'package:sqflite/sqflite.dart';
|
||||||
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
||||||
|
|
||||||
|
import '../models/vendedor.dart';
|
||||||
|
import '../models/cliente.dart';
|
||||||
|
import '../models/producto.dart';
|
||||||
|
import '../models/pedido.dart';
|
||||||
|
import '../models/item_pedido.dart';
|
||||||
|
import '../models/ruta.dart';
|
||||||
|
import '../models/parada_ruta.dart';
|
||||||
|
|
||||||
|
class DatabaseHelper {
|
||||||
|
static final DatabaseHelper _instance = DatabaseHelper._();
|
||||||
|
factory DatabaseHelper() => _instance;
|
||||||
|
DatabaseHelper._();
|
||||||
|
|
||||||
|
static Database? _db;
|
||||||
|
|
||||||
|
Future<Database> get database async {
|
||||||
|
_db ??= await _initDB();
|
||||||
|
return _db!;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Database> _initDB() async {
|
||||||
|
if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) {
|
||||||
|
sqfliteFfiInit();
|
||||||
|
final dbPath = await databaseFactoryFfi.getDatabasesPath();
|
||||||
|
final path = join(dbPath, 'telcotronics.db');
|
||||||
|
return databaseFactoryFfi.openDatabase(
|
||||||
|
path,
|
||||||
|
options: OpenDatabaseOptions(version: 1, onCreate: _createTables),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final dbPath = await getDatabasesPath();
|
||||||
|
final path = join(dbPath, 'telcotronics.db');
|
||||||
|
return openDatabase(path, version: 1, onCreate: _createTables);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _createTables(Database db, int version) async {
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE usuarios (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
nombre TEXT NOT NULL,
|
||||||
|
email TEXT NOT NULL UNIQUE,
|
||||||
|
password TEXT NOT NULL,
|
||||||
|
telefono TEXT,
|
||||||
|
zona TEXT,
|
||||||
|
avatar_initials TEXT
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE clientes (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
nombre TEXT NOT NULL,
|
||||||
|
razon_social TEXT,
|
||||||
|
direccion TEXT,
|
||||||
|
telefono TEXT,
|
||||||
|
nit TEXT,
|
||||||
|
lat REAL DEFAULT 0,
|
||||||
|
lng REAL DEFAULT 0,
|
||||||
|
categoria TEXT DEFAULT 'Minorista'
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE productos (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
sku TEXT UNIQUE NOT NULL,
|
||||||
|
nombre TEXT NOT NULL,
|
||||||
|
descripcion TEXT,
|
||||||
|
categoria TEXT,
|
||||||
|
precio REAL NOT NULL,
|
||||||
|
precio_mayorista REAL NOT NULL,
|
||||||
|
unidad TEXT DEFAULT 'unidad',
|
||||||
|
stock INTEGER DEFAULT 0,
|
||||||
|
emoji TEXT DEFAULT '📦'
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE rutas (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
nombre TEXT NOT NULL,
|
||||||
|
zona TEXT,
|
||||||
|
fecha TEXT NOT NULL
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE paradas_ruta (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
ruta_id TEXT NOT NULL,
|
||||||
|
cliente_id TEXT NOT NULL,
|
||||||
|
orden INTEGER NOT NULL,
|
||||||
|
estado TEXT NOT NULL DEFAULT 'pendiente',
|
||||||
|
hora_estimada TEXT,
|
||||||
|
hora_visita TEXT,
|
||||||
|
notas_visita TEXT,
|
||||||
|
FOREIGN KEY (ruta_id) REFERENCES rutas(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (cliente_id) REFERENCES clientes(id)
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE pedidos (
|
||||||
|
id TEXT PRIMARY KEY,
|
||||||
|
cliente_id TEXT NOT NULL,
|
||||||
|
estado TEXT NOT NULL DEFAULT 'pendiente',
|
||||||
|
fecha TEXT NOT NULL,
|
||||||
|
notas TEXT,
|
||||||
|
firma_base64 TEXT,
|
||||||
|
FOREIGN KEY (cliente_id) REFERENCES clientes(id)
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
|
||||||
|
await db.execute('''
|
||||||
|
CREATE TABLE items_pedido (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
pedido_id TEXT NOT NULL,
|
||||||
|
producto_id TEXT NOT NULL,
|
||||||
|
cantidad INTEGER NOT NULL,
|
||||||
|
precio_unitario REAL NOT NULL,
|
||||||
|
FOREIGN KEY (pedido_id) REFERENCES pedidos(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (producto_id) REFERENCES productos(id)
|
||||||
|
)
|
||||||
|
''');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Usuarios ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<void> insertUsuario(Vendedor v, String password) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.insert('usuarios', {...v.toMap(), 'password': password},
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>?> loginUsuario(String email, String password) async {
|
||||||
|
final db = await database;
|
||||||
|
final rows = await db.query('usuarios',
|
||||||
|
where: 'email = ? AND password = ?', whereArgs: [email, password]);
|
||||||
|
return rows.isEmpty ? null : rows.first;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Vendedor?> getVendedor(String id) async {
|
||||||
|
final db = await database;
|
||||||
|
final rows = await db.query('usuarios', where: 'id = ?', whereArgs: [id]);
|
||||||
|
return rows.isEmpty ? null : Vendedor.fromMap(rows.first);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Clientes ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<List<Cliente>> getClientes() async {
|
||||||
|
final db = await database;
|
||||||
|
final rows = await db.query('clientes', orderBy: 'nombre ASC');
|
||||||
|
return rows.map(Cliente.fromMap).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> insertCliente(Cliente c) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.insert('clientes', c.toMap(),
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateCliente(Cliente c) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.update('clientes', c.toMap(), where: 'id = ?', whereArgs: [c.id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteCliente(String id) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.delete('clientes', where: 'id = ?', whereArgs: [id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Productos ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<List<Producto>> getProductos() async {
|
||||||
|
final db = await database;
|
||||||
|
final rows = await db.query('productos', orderBy: 'categoria ASC, nombre ASC');
|
||||||
|
return rows.map(Producto.fromMap).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> insertProducto(Producto p) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.insert('productos', p.toMap(),
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateProducto(Producto p) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.update('productos', p.toMap(), where: 'id = ?', whereArgs: [p.id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateStock(String productoId, int nuevoStock) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.update('productos', {'stock': nuevoStock},
|
||||||
|
where: 'id = ?', whereArgs: [productoId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Rutas ────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<String?> getRutaIdHoy() async {
|
||||||
|
final db = await database;
|
||||||
|
final hoy = DateTime.now().toIso8601String().substring(0, 10);
|
||||||
|
final rows = await db.query('rutas',
|
||||||
|
where: "fecha LIKE ?", whereArgs: ['$hoy%']);
|
||||||
|
return rows.isEmpty ? null : rows.first['id'] as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Ruta?> getRutaConParadas(
|
||||||
|
String rutaId, Map<String, Cliente> clientesMap) async {
|
||||||
|
final db = await database;
|
||||||
|
final rutaRows = await db.query('rutas', where: 'id = ?', whereArgs: [rutaId]);
|
||||||
|
if (rutaRows.isEmpty) return null;
|
||||||
|
final r = rutaRows.first;
|
||||||
|
|
||||||
|
final paradaRows = await db.query('paradas_ruta',
|
||||||
|
where: 'ruta_id = ?', whereArgs: [rutaId], orderBy: 'orden ASC');
|
||||||
|
|
||||||
|
final paradas = paradaRows.map((row) {
|
||||||
|
final cliente = clientesMap[row['cliente_id'] as String];
|
||||||
|
if (cliente == null) return null;
|
||||||
|
return ParadaRuta(
|
||||||
|
id: row['id'] as String,
|
||||||
|
cliente: cliente,
|
||||||
|
orden: row['orden'] as int,
|
||||||
|
estado: EstadoParadaExt.fromString(row['estado'] as String),
|
||||||
|
horaEstimada: row['hora_estimada'] as String? ?? '',
|
||||||
|
horaVisita: row['hora_visita'] as String?,
|
||||||
|
notasVisita: row['notas_visita'] as String?,
|
||||||
|
);
|
||||||
|
}).whereType<ParadaRuta>().toList();
|
||||||
|
|
||||||
|
return Ruta(
|
||||||
|
id: r['id'] as String,
|
||||||
|
nombre: r['nombre'] as String,
|
||||||
|
zona: r['zona'] as String? ?? '',
|
||||||
|
paradas: paradas,
|
||||||
|
fecha: DateTime.parse(r['fecha'] as String),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> insertRuta(Ruta ruta) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.insert('rutas', ruta.toMap(),
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace);
|
||||||
|
return ruta.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> insertParada(ParadaRuta parada, String rutaId) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.insert('paradas_ruta', parada.toMap(rutaId),
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateParadaEstado(
|
||||||
|
String paradaId, String estado, String? horaVisita) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.update(
|
||||||
|
'paradas_ruta',
|
||||||
|
{'estado': estado, 'hora_visita': horaVisita},
|
||||||
|
where: 'id = ?',
|
||||||
|
whereArgs: [paradaId],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteParada(String paradaId) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.delete('paradas_ruta', where: 'id = ?', whereArgs: [paradaId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> reordenarParadas(List<ParadaRuta> paradas, String rutaId) async {
|
||||||
|
final db = await database;
|
||||||
|
final batch = db.batch();
|
||||||
|
for (int i = 0; i < paradas.length; i++) {
|
||||||
|
batch.update('paradas_ruta', {'orden': i + 1},
|
||||||
|
where: 'id = ?', whereArgs: [paradas[i].id]);
|
||||||
|
}
|
||||||
|
await batch.commit(noResult: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Pedidos ─────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<List<Pedido>> getPedidos(
|
||||||
|
Map<String, Cliente> clientesMap, Map<String, Producto> productosMap) async {
|
||||||
|
final db = await database;
|
||||||
|
final pedidoRows = await db.query('pedidos', orderBy: 'fecha DESC');
|
||||||
|
|
||||||
|
final pedidos = <Pedido>[];
|
||||||
|
for (final row in pedidoRows) {
|
||||||
|
final cliente = clientesMap[row['cliente_id'] as String];
|
||||||
|
if (cliente == null) continue;
|
||||||
|
|
||||||
|
final itemRows = await db.query('items_pedido',
|
||||||
|
where: 'pedido_id = ?', whereArgs: [row['id']]);
|
||||||
|
|
||||||
|
final items = itemRows.map((ir) {
|
||||||
|
final producto = productosMap[ir['producto_id'] as String];
|
||||||
|
if (producto == null) return null;
|
||||||
|
return ItemPedido(
|
||||||
|
dbId: ir['id'] as int?,
|
||||||
|
producto: producto,
|
||||||
|
cantidad: ir['cantidad'] as int,
|
||||||
|
precioUnitario: (ir['precio_unitario'] as num).toDouble(),
|
||||||
|
);
|
||||||
|
}).whereType<ItemPedido>().toList();
|
||||||
|
|
||||||
|
pedidos.add(Pedido(
|
||||||
|
id: row['id'] as String,
|
||||||
|
cliente: cliente,
|
||||||
|
estado: EstadoPedidoExt.fromString(row['estado'] as String),
|
||||||
|
fecha: DateTime.parse(row['fecha'] as String),
|
||||||
|
notas: row['notas'] as String? ?? '',
|
||||||
|
firmaBase64: row['firma_base64'] as String?,
|
||||||
|
items: items,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return pedidos;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> insertPedido(Pedido pedido) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.insert('pedidos', pedido.toMap(),
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace);
|
||||||
|
for (final item in pedido.items) {
|
||||||
|
await db.insert('items_pedido', item.toMap(pedido.id),
|
||||||
|
conflictAlgorithm: ConflictAlgorithm.replace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateEstadoPedido(String pedidoId, String estado) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.update('pedidos', {'estado': estado},
|
||||||
|
where: 'id = ?', whereArgs: [pedidoId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateFirmaPedido(String pedidoId, String firma) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.update('pedidos', {'firma_base64': firma, 'estado': 'confirmado'},
|
||||||
|
where: 'id = ?', whereArgs: [pedidoId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deletePedido(String pedidoId) async {
|
||||||
|
final db = await database;
|
||||||
|
await db.delete('pedidos', where: 'id = ?', whereArgs: [pedidoId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Utilidades ───────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<bool> isSeeded() async {
|
||||||
|
final db = await database;
|
||||||
|
final rows = await db.query('productos', limit: 1);
|
||||||
|
return rows.isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> close() async => (await database).close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import 'database_helper.dart';
|
||||||
|
import '../data/mock_data.dart';
|
||||||
|
|
||||||
|
class DbSeeder {
|
||||||
|
final DatabaseHelper _db;
|
||||||
|
DbSeeder(this._db);
|
||||||
|
|
||||||
|
Future<void> seed() async {
|
||||||
|
// Guardar usuario admin
|
||||||
|
await _db.insertUsuario(MockData.vendedor, 'Microbot%');
|
||||||
|
|
||||||
|
// Clientes
|
||||||
|
for (final c in MockData.clientes) {
|
||||||
|
await _db.insertCliente(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Productos
|
||||||
|
for (final p in MockData.productos) {
|
||||||
|
await _db.insertProducto(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ruta del día
|
||||||
|
final ruta = MockData.buildRuta();
|
||||||
|
await _db.insertRuta(ruta);
|
||||||
|
for (final parada in ruta.paradas) {
|
||||||
|
await _db.insertParada(parada, ruta.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pedidos históricos
|
||||||
|
final pedidos = MockData.buildPedidos();
|
||||||
|
for (final pedido in pedidos) {
|
||||||
|
await _db.insertPedido(pedido);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:intl/date_symbol_data_local.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'app.dart';
|
||||||
|
import 'providers/app_provider.dart';
|
||||||
|
import 'services/notification_service.dart';
|
||||||
|
|
||||||
|
final _navigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
|
void main() async {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
await initializeDateFormatting('es', null);
|
||||||
|
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||||
|
statusBarColor: Colors.transparent,
|
||||||
|
statusBarIconBrightness: Brightness.light,
|
||||||
|
));
|
||||||
|
|
||||||
|
final notifService = NotificationService(navigatorKey: _navigatorKey);
|
||||||
|
|
||||||
|
runApp(
|
||||||
|
MultiProvider(
|
||||||
|
providers: [
|
||||||
|
ChangeNotifierProvider(
|
||||||
|
create: (_) => AppProvider(notifService: notifService),
|
||||||
|
),
|
||||||
|
ChangeNotifierProvider.value(value: notifService),
|
||||||
|
],
|
||||||
|
child: PedidosApp(navigatorKey: _navigatorKey),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
class Cliente {
|
||||||
|
final String id;
|
||||||
|
final String nombre;
|
||||||
|
final String razonSocial;
|
||||||
|
final String direccion;
|
||||||
|
final String telefono;
|
||||||
|
final String nit;
|
||||||
|
final double lat;
|
||||||
|
final double lng;
|
||||||
|
final String categoria;
|
||||||
|
|
||||||
|
const Cliente({
|
||||||
|
required this.id,
|
||||||
|
required this.nombre,
|
||||||
|
required this.razonSocial,
|
||||||
|
required this.direccion,
|
||||||
|
required this.telefono,
|
||||||
|
required this.nit,
|
||||||
|
required this.lat,
|
||||||
|
required this.lng,
|
||||||
|
required this.categoria,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() => {
|
||||||
|
'id': id,
|
||||||
|
'nombre': nombre,
|
||||||
|
'razon_social': razonSocial,
|
||||||
|
'direccion': direccion,
|
||||||
|
'telefono': telefono,
|
||||||
|
'nit': nit,
|
||||||
|
'lat': lat,
|
||||||
|
'lng': lng,
|
||||||
|
'categoria': categoria,
|
||||||
|
};
|
||||||
|
|
||||||
|
factory Cliente.fromMap(Map<String, dynamic> m) => Cliente(
|
||||||
|
id: m['id'] as String,
|
||||||
|
nombre: m['nombre'] as String,
|
||||||
|
razonSocial: m['razon_social'] as String? ?? '',
|
||||||
|
direccion: m['direccion'] as String? ?? '',
|
||||||
|
telefono: m['telefono'] as String? ?? '',
|
||||||
|
nit: m['nit'] as String? ?? '',
|
||||||
|
lat: (m['lat'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
lng: (m['lng'] as num?)?.toDouble() ?? 0.0,
|
||||||
|
categoria: m['categoria'] as String? ?? 'Minorista',
|
||||||
|
);
|
||||||
|
|
||||||
|
Cliente copyWith({
|
||||||
|
String? nombre, String? razonSocial, String? direccion,
|
||||||
|
String? telefono, String? nit, String? categoria,
|
||||||
|
}) => Cliente(
|
||||||
|
id: id, lat: lat, lng: lng,
|
||||||
|
nombre: nombre ?? this.nombre,
|
||||||
|
razonSocial: razonSocial ?? this.razonSocial,
|
||||||
|
direccion: direccion ?? this.direccion,
|
||||||
|
telefono: telefono ?? this.telefono,
|
||||||
|
nit: nit ?? this.nit,
|
||||||
|
categoria: categoria ?? this.categoria,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import 'producto.dart';
|
||||||
|
|
||||||
|
class ItemPedido {
|
||||||
|
final int? dbId;
|
||||||
|
final Producto producto;
|
||||||
|
int cantidad;
|
||||||
|
double precioUnitario;
|
||||||
|
|
||||||
|
ItemPedido({
|
||||||
|
this.dbId,
|
||||||
|
required this.producto,
|
||||||
|
required this.cantidad,
|
||||||
|
required this.precioUnitario,
|
||||||
|
});
|
||||||
|
|
||||||
|
double get subtotal => cantidad * precioUnitario;
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap(String pedidoId) => {
|
||||||
|
if (dbId != null) 'id': dbId,
|
||||||
|
'pedido_id': pedidoId,
|
||||||
|
'producto_id': producto.id,
|
||||||
|
'cantidad': cantidad,
|
||||||
|
'precio_unitario': precioUnitario,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
enum TipoNotificacion {
|
||||||
|
pedidoConfirmado,
|
||||||
|
pedidoEntregado,
|
||||||
|
paradaProxima,
|
||||||
|
stockBajo,
|
||||||
|
metaVentas,
|
||||||
|
recordatorio,
|
||||||
|
alerta,
|
||||||
|
}
|
||||||
|
|
||||||
|
extension TipoNotificacionExt on TipoNotificacion {
|
||||||
|
String get label {
|
||||||
|
switch (this) {
|
||||||
|
case TipoNotificacion.pedidoConfirmado: return 'Pedido confirmado';
|
||||||
|
case TipoNotificacion.pedidoEntregado: return 'Pedido entregado';
|
||||||
|
case TipoNotificacion.paradaProxima: return 'Próxima parada';
|
||||||
|
case TipoNotificacion.stockBajo: return 'Stock bajo';
|
||||||
|
case TipoNotificacion.metaVentas: return 'Meta de ventas';
|
||||||
|
case TipoNotificacion.recordatorio: return 'Recordatorio';
|
||||||
|
case TipoNotificacion.alerta: return 'Alerta';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IconData get icono {
|
||||||
|
switch (this) {
|
||||||
|
case TipoNotificacion.pedidoConfirmado: return Icons.receipt_long;
|
||||||
|
case TipoNotificacion.pedidoEntregado: return Icons.local_shipping;
|
||||||
|
case TipoNotificacion.paradaProxima: return Icons.location_on;
|
||||||
|
case TipoNotificacion.stockBajo: return Icons.inventory_2;
|
||||||
|
case TipoNotificacion.metaVentas: return Icons.trending_up;
|
||||||
|
case TipoNotificacion.recordatorio: return Icons.alarm;
|
||||||
|
case TipoNotificacion.alerta: return Icons.warning_amber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color get color {
|
||||||
|
switch (this) {
|
||||||
|
case TipoNotificacion.pedidoConfirmado: return const Color(0xFF16A34A);
|
||||||
|
case TipoNotificacion.pedidoEntregado: return const Color(0xFF0891B2);
|
||||||
|
case TipoNotificacion.paradaProxima: return const Color(0xFF2563EB);
|
||||||
|
case TipoNotificacion.stockBajo: return const Color(0xFFD97706);
|
||||||
|
case TipoNotificacion.metaVentas: return const Color(0xFF7C3AED);
|
||||||
|
case TipoNotificacion.recordatorio: return const Color(0xFF0891B2);
|
||||||
|
case TipoNotificacion.alerta: return const Color(0xFFDC2626);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Notificacion {
|
||||||
|
final String id;
|
||||||
|
final TipoNotificacion tipo;
|
||||||
|
final String titulo;
|
||||||
|
final String cuerpo;
|
||||||
|
final DateTime fecha;
|
||||||
|
bool leida;
|
||||||
|
final String? accionId;
|
||||||
|
|
||||||
|
Notificacion({
|
||||||
|
required this.id,
|
||||||
|
required this.tipo,
|
||||||
|
required this.titulo,
|
||||||
|
required this.cuerpo,
|
||||||
|
required this.fecha,
|
||||||
|
this.leida = false,
|
||||||
|
this.accionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import 'cliente.dart';
|
||||||
|
|
||||||
|
enum EstadoParada { pendiente, visitado, saltado }
|
||||||
|
|
||||||
|
extension EstadoParadaExt on EstadoParada {
|
||||||
|
String get value {
|
||||||
|
switch (this) {
|
||||||
|
case EstadoParada.visitado: return 'visitado';
|
||||||
|
case EstadoParada.saltado: return 'saltado';
|
||||||
|
default: return 'pendiente';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static EstadoParada fromString(String s) {
|
||||||
|
switch (s) {
|
||||||
|
case 'visitado': return EstadoParada.visitado;
|
||||||
|
case 'saltado': return EstadoParada.saltado;
|
||||||
|
default: return EstadoParada.pendiente;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ParadaRuta {
|
||||||
|
final String id;
|
||||||
|
final Cliente cliente;
|
||||||
|
final int orden;
|
||||||
|
EstadoParada estado;
|
||||||
|
final String horaEstimada;
|
||||||
|
String? horaVisita;
|
||||||
|
String? notasVisita;
|
||||||
|
|
||||||
|
ParadaRuta({
|
||||||
|
required this.id,
|
||||||
|
required this.cliente,
|
||||||
|
required this.orden,
|
||||||
|
required this.estado,
|
||||||
|
required this.horaEstimada,
|
||||||
|
this.horaVisita,
|
||||||
|
this.notasVisita,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap(String rutaId) => {
|
||||||
|
'id': id,
|
||||||
|
'ruta_id': rutaId,
|
||||||
|
'cliente_id': cliente.id,
|
||||||
|
'orden': orden,
|
||||||
|
'estado': estado.value,
|
||||||
|
'hora_estimada': horaEstimada,
|
||||||
|
'hora_visita': horaVisita,
|
||||||
|
'notas_visita': notasVisita,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import 'cliente.dart';
|
||||||
|
import 'item_pedido.dart';
|
||||||
|
|
||||||
|
enum EstadoPedido { pendiente, confirmado, entregado, cancelado }
|
||||||
|
|
||||||
|
extension EstadoPedidoExt on EstadoPedido {
|
||||||
|
String get label {
|
||||||
|
switch (this) {
|
||||||
|
case EstadoPedido.pendiente: return 'Pendiente';
|
||||||
|
case EstadoPedido.confirmado: return 'Confirmado';
|
||||||
|
case EstadoPedido.entregado: return 'Entregado';
|
||||||
|
case EstadoPedido.cancelado: return 'Cancelado';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static EstadoPedido fromString(String s) {
|
||||||
|
switch (s) {
|
||||||
|
case 'confirmado': return EstadoPedido.confirmado;
|
||||||
|
case 'entregado': return EstadoPedido.entregado;
|
||||||
|
case 'cancelado': return EstadoPedido.cancelado;
|
||||||
|
default: return EstadoPedido.pendiente;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Pedido {
|
||||||
|
final String id;
|
||||||
|
final Cliente cliente;
|
||||||
|
final List<ItemPedido> items;
|
||||||
|
EstadoPedido estado;
|
||||||
|
final DateTime fecha;
|
||||||
|
String notas;
|
||||||
|
String? firmaBase64;
|
||||||
|
|
||||||
|
Pedido({
|
||||||
|
required this.id,
|
||||||
|
required this.cliente,
|
||||||
|
required this.items,
|
||||||
|
required this.estado,
|
||||||
|
required this.fecha,
|
||||||
|
this.notas = '',
|
||||||
|
this.firmaBase64,
|
||||||
|
});
|
||||||
|
|
||||||
|
double get subtotal => items.fold(0, (s, i) => s + i.subtotal);
|
||||||
|
double get total => subtotal;
|
||||||
|
int get totalItems => items.fold(0, (s, i) => s + i.cantidad);
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() => {
|
||||||
|
'id': id,
|
||||||
|
'cliente_id': cliente.id,
|
||||||
|
'estado': estado.label.toLowerCase(),
|
||||||
|
'fecha': fecha.toIso8601String(),
|
||||||
|
'notas': notas,
|
||||||
|
'firma_base64': firmaBase64,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
class Producto {
|
||||||
|
final String id;
|
||||||
|
final String nombre;
|
||||||
|
final String descripcion;
|
||||||
|
final String categoria;
|
||||||
|
final double precio;
|
||||||
|
final double precioMayorista;
|
||||||
|
final String unidad;
|
||||||
|
final int stock;
|
||||||
|
final String sku;
|
||||||
|
final String emoji;
|
||||||
|
|
||||||
|
const Producto({
|
||||||
|
required this.id,
|
||||||
|
required this.nombre,
|
||||||
|
required this.descripcion,
|
||||||
|
required this.categoria,
|
||||||
|
required this.precio,
|
||||||
|
required this.precioMayorista,
|
||||||
|
required this.unidad,
|
||||||
|
required this.stock,
|
||||||
|
required this.sku,
|
||||||
|
required this.emoji,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() => {
|
||||||
|
'id': id,
|
||||||
|
'sku': sku,
|
||||||
|
'nombre': nombre,
|
||||||
|
'descripcion': descripcion,
|
||||||
|
'categoria': categoria,
|
||||||
|
'precio': precio,
|
||||||
|
'precio_mayorista': precioMayorista,
|
||||||
|
'unidad': unidad,
|
||||||
|
'stock': stock,
|
||||||
|
'emoji': emoji,
|
||||||
|
};
|
||||||
|
|
||||||
|
factory Producto.fromMap(Map<String, dynamic> m) => Producto(
|
||||||
|
id: m['id'] as String,
|
||||||
|
sku: m['sku'] as String? ?? '',
|
||||||
|
nombre: m['nombre'] as String,
|
||||||
|
descripcion: m['descripcion'] as String? ?? '',
|
||||||
|
categoria: m['categoria'] as String? ?? '',
|
||||||
|
precio: (m['precio'] as num).toDouble(),
|
||||||
|
precioMayorista: (m['precio_mayorista'] as num).toDouble(),
|
||||||
|
unidad: m['unidad'] as String? ?? 'unidad',
|
||||||
|
stock: m['stock'] as int? ?? 0,
|
||||||
|
emoji: m['emoji'] as String? ?? '📦',
|
||||||
|
);
|
||||||
|
|
||||||
|
Producto copyWith({int? stock, double? precio, double? precioMayorista}) => Producto(
|
||||||
|
id: id, sku: sku, nombre: nombre, descripcion: descripcion,
|
||||||
|
categoria: categoria, unidad: unidad, emoji: emoji,
|
||||||
|
precio: precio ?? this.precio,
|
||||||
|
precioMayorista: precioMayorista ?? this.precioMayorista,
|
||||||
|
stock: stock ?? this.stock,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import 'parada_ruta.dart';
|
||||||
|
|
||||||
|
class Ruta {
|
||||||
|
final String id;
|
||||||
|
final String nombre;
|
||||||
|
final String zona;
|
||||||
|
final List<ParadaRuta> paradas;
|
||||||
|
final DateTime fecha;
|
||||||
|
|
||||||
|
Ruta({
|
||||||
|
required this.id,
|
||||||
|
required this.nombre,
|
||||||
|
required this.zona,
|
||||||
|
required this.paradas,
|
||||||
|
required this.fecha,
|
||||||
|
});
|
||||||
|
|
||||||
|
int get visitadas => paradas.where((p) => p.estado == EstadoParada.visitado).length;
|
||||||
|
int get pendientes => paradas.where((p) => p.estado == EstadoParada.pendiente).length;
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() => {
|
||||||
|
'id': id,
|
||||||
|
'nombre': nombre,
|
||||||
|
'zona': zona,
|
||||||
|
'fecha': fecha.toIso8601String(),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
class Vendedor {
|
||||||
|
final String id;
|
||||||
|
final String nombre;
|
||||||
|
final String email;
|
||||||
|
final String telefono;
|
||||||
|
final String zona;
|
||||||
|
final String avatarInitials;
|
||||||
|
|
||||||
|
const Vendedor({
|
||||||
|
required this.id,
|
||||||
|
required this.nombre,
|
||||||
|
required this.email,
|
||||||
|
required this.telefono,
|
||||||
|
required this.zona,
|
||||||
|
required this.avatarInitials,
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() => {
|
||||||
|
'id': id,
|
||||||
|
'nombre': nombre,
|
||||||
|
'email': email,
|
||||||
|
'telefono': telefono,
|
||||||
|
'zona': zona,
|
||||||
|
'avatar_initials': avatarInitials,
|
||||||
|
};
|
||||||
|
|
||||||
|
factory Vendedor.fromMap(Map<String, dynamic> m) => Vendedor(
|
||||||
|
id: m['id'] as String,
|
||||||
|
nombre: m['nombre'] as String,
|
||||||
|
email: m['email'] as String,
|
||||||
|
telefono: m['telefono'] as String? ?? '',
|
||||||
|
zona: m['zona'] as String? ?? '',
|
||||||
|
avatarInitials: m['avatar_initials'] as String? ?? '',
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,311 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import '../database/database_helper.dart';
|
||||||
|
import '../database/db_seeder.dart';
|
||||||
|
import '../models/vendedor.dart';
|
||||||
|
import '../models/cliente.dart';
|
||||||
|
import '../models/producto.dart';
|
||||||
|
import '../models/pedido.dart';
|
||||||
|
import '../models/item_pedido.dart';
|
||||||
|
import '../models/ruta.dart';
|
||||||
|
import '../models/parada_ruta.dart';
|
||||||
|
import '../services/notification_service.dart';
|
||||||
|
|
||||||
|
class AppProvider extends ChangeNotifier {
|
||||||
|
final _db = DatabaseHelper();
|
||||||
|
final NotificationService? _notifService;
|
||||||
|
|
||||||
|
AppProvider({NotificationService? notifService}) : _notifService = notifService;
|
||||||
|
|
||||||
|
// ── Estado de sesión ─────────────────────────────────────────
|
||||||
|
bool _isLoggedIn = false;
|
||||||
|
bool _loading = false;
|
||||||
|
String? _loginError;
|
||||||
|
Vendedor? _vendedor;
|
||||||
|
Ruta? _ruta;
|
||||||
|
List<Pedido> _pedidos = [];
|
||||||
|
List<Producto> _productos = [];
|
||||||
|
List<Cliente> _clientes = [];
|
||||||
|
|
||||||
|
// índices en memoria para joins rápidos
|
||||||
|
Map<String, Cliente> _clientesMap = {};
|
||||||
|
Map<String, Producto> _productosMap = {};
|
||||||
|
|
||||||
|
// ── Carrito activo ───────────────────────────────────────────
|
||||||
|
Cliente? _clienteSeleccionado;
|
||||||
|
final List<ItemPedido> _carrito = [];
|
||||||
|
String _notasPedido = '';
|
||||||
|
|
||||||
|
// ── Getters ──────────────────────────────────────────────────
|
||||||
|
bool get isLoggedIn => _isLoggedIn;
|
||||||
|
bool get loading => _loading;
|
||||||
|
String? get loginError => _loginError;
|
||||||
|
|
||||||
|
Vendedor get vendedor => _vendedor!;
|
||||||
|
Ruta get ruta => _ruta!;
|
||||||
|
List<Pedido> get pedidos => _pedidos;
|
||||||
|
List<Producto> get productos => _productos;
|
||||||
|
List<Cliente> get clientes => _clientes;
|
||||||
|
|
||||||
|
Cliente? get clienteSeleccionado => _clienteSeleccionado;
|
||||||
|
List<ItemPedido> get carrito => _carrito;
|
||||||
|
String get notasPedido => _notasPedido;
|
||||||
|
|
||||||
|
double get totalCarrito => _carrito.fold(0, (s, i) => s + i.subtotal);
|
||||||
|
int get cantidadCarrito => _carrito.fold(0, (s, i) => s + i.cantidad);
|
||||||
|
|
||||||
|
List<Cliente> get clientesSinParada {
|
||||||
|
final ids = _ruta?.paradas.map((p) => p.cliente.id).toSet() ?? {};
|
||||||
|
return _clientes.where((c) => !ids.contains(c.id)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Stats del día ────────────────────────────────────────────
|
||||||
|
int get pedidosHoy => _pedidos.where((p) {
|
||||||
|
final now = DateTime.now();
|
||||||
|
return p.fecha.day == now.day && p.fecha.month == now.month &&
|
||||||
|
p.estado != EstadoPedido.cancelado;
|
||||||
|
}).length;
|
||||||
|
|
||||||
|
double get ventasTotalesHoy => _pedidos.where((p) {
|
||||||
|
final now = DateTime.now();
|
||||||
|
return p.fecha.day == now.day && p.fecha.month == now.month &&
|
||||||
|
p.estado != EstadoPedido.cancelado;
|
||||||
|
}).fold(0, (s, p) => s + p.total);
|
||||||
|
|
||||||
|
// ── Login / Logout ───────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<bool> login(String email, String password) async {
|
||||||
|
_loginError = null;
|
||||||
|
_loading = true;
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
|
// Seed si es la primera vez
|
||||||
|
final seeded = await _db.isSeeded();
|
||||||
|
if (!seeded) await DbSeeder(_db).seed();
|
||||||
|
|
||||||
|
final row = await _db.loginUsuario(email.trim(), password);
|
||||||
|
if (row == null) {
|
||||||
|
_loginError = 'Correo o contraseña incorrectos';
|
||||||
|
_loading = false;
|
||||||
|
notifyListeners();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_vendedor = Vendedor.fromMap(row);
|
||||||
|
await _loadAllData();
|
||||||
|
|
||||||
|
_loading = false;
|
||||||
|
_isLoggedIn = true;
|
||||||
|
notifyListeners();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadAllData() async {
|
||||||
|
// 1. catálogo y clientes (base para joins)
|
||||||
|
_productos = await _db.getProductos();
|
||||||
|
_clientes = await _db.getClientes();
|
||||||
|
_productosMap = {for (final p in _productos) p.id: p};
|
||||||
|
_clientesMap = {for (final c in _clientes) c.id: c};
|
||||||
|
|
||||||
|
// 2. Ruta de hoy (o crear una vacía)
|
||||||
|
final rutaId = await _db.getRutaIdHoy();
|
||||||
|
if (rutaId != null) {
|
||||||
|
_ruta = await _db.getRutaConParadas(rutaId, _clientesMap) ?? _emptyRuta();
|
||||||
|
} else {
|
||||||
|
_ruta = _emptyRuta();
|
||||||
|
await _db.insertRuta(_ruta!);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Pedidos
|
||||||
|
_pedidos = await _db.getPedidos(_clientesMap, _productosMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ruta _emptyRuta() => Ruta(
|
||||||
|
id: 'ruta_${DateTime.now().toIso8601String().substring(0, 10)}',
|
||||||
|
nombre: 'Ruta del día',
|
||||||
|
zona: _vendedor?.zona ?? '',
|
||||||
|
paradas: [],
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
);
|
||||||
|
|
||||||
|
void logout() {
|
||||||
|
_isLoggedIn = false;
|
||||||
|
_vendedor = null;
|
||||||
|
_ruta = null;
|
||||||
|
_pedidos = [];
|
||||||
|
_productos = [];
|
||||||
|
_clientes = [];
|
||||||
|
_clientesMap = {};
|
||||||
|
_productosMap = {};
|
||||||
|
limpiarCarrito();
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Clientes ─────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<void> agregarCliente(Cliente cliente, {bool agregarARuta = false}) async {
|
||||||
|
await _db.insertCliente(cliente);
|
||||||
|
_clientes.add(cliente);
|
||||||
|
_clientesMap[cliente.id] = cliente;
|
||||||
|
if (agregarARuta) {
|
||||||
|
await agregarParadaARuta(cliente, _horaDefault());
|
||||||
|
} else {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> actualizarCliente(Cliente cliente) async {
|
||||||
|
await _db.updateCliente(cliente);
|
||||||
|
final idx = _clientes.indexWhere((c) => c.id == cliente.id);
|
||||||
|
if (idx >= 0) _clientes[idx] = cliente;
|
||||||
|
_clientesMap[cliente.id] = cliente;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Productos ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<void> actualizarStock(String productoId, int nuevoStock) async {
|
||||||
|
await _db.updateStock(productoId, nuevoStock);
|
||||||
|
final idx = _productos.indexWhere((p) => p.id == productoId);
|
||||||
|
if (idx >= 0) {
|
||||||
|
_productos[idx] = _productos[idx].copyWith(stock: nuevoStock);
|
||||||
|
_productosMap[productoId] = _productos[idx];
|
||||||
|
if (nuevoStock <= 5) {
|
||||||
|
_notifService?.notifStockBajo(_productos[idx].nombre, nuevoStock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Ruta / Paradas ───────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<void> agregarParadaARuta(Cliente cliente, String horaEstimada) async {
|
||||||
|
final nuevaOrden = (_ruta?.paradas.length ?? 0) + 1;
|
||||||
|
final parada = ParadaRuta(
|
||||||
|
id: 'pr_${DateTime.now().millisecondsSinceEpoch}',
|
||||||
|
cliente: cliente,
|
||||||
|
orden: nuevaOrden,
|
||||||
|
estado: EstadoParada.pendiente,
|
||||||
|
horaEstimada: horaEstimada,
|
||||||
|
);
|
||||||
|
await _db.insertParada(parada, _ruta!.id);
|
||||||
|
_ruta!.paradas.add(parada);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> eliminarParada(String paradaId) async {
|
||||||
|
await _db.deleteParada(paradaId);
|
||||||
|
_ruta!.paradas.removeWhere((p) => p.id == paradaId);
|
||||||
|
// reordenar
|
||||||
|
for (int i = 0; i < _ruta!.paradas.length; i++) {
|
||||||
|
_ruta!.paradas[i] = ParadaRuta(
|
||||||
|
id: _ruta!.paradas[i].id,
|
||||||
|
cliente: _ruta!.paradas[i].cliente,
|
||||||
|
orden: i + 1,
|
||||||
|
estado: _ruta!.paradas[i].estado,
|
||||||
|
horaEstimada: _ruta!.paradas[i].horaEstimada,
|
||||||
|
horaVisita: _ruta!.paradas[i].horaVisita,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await _db.reordenarParadas(_ruta!.paradas, _ruta!.id);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> marcarParadaVisitada(String paradaId) async {
|
||||||
|
final hora = _horaActual();
|
||||||
|
await _db.updateParadaEstado(paradaId, 'visitado', hora);
|
||||||
|
final parada = _ruta!.paradas.firstWhere((p) => p.id == paradaId);
|
||||||
|
parada.estado = EstadoParada.visitado;
|
||||||
|
parada.horaVisita = hora;
|
||||||
|
_notifService?.notifParadaVisitada(parada.cliente.nombre);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Carrito ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
void seleccionarCliente(Cliente cliente) {
|
||||||
|
_clienteSeleccionado = cliente;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void agregarAlCarrito(Producto producto, {bool esMayorista = false}) {
|
||||||
|
final precio = esMayorista ? producto.precioMayorista : producto.precio;
|
||||||
|
final existente = _carrito.where((i) => i.producto.id == producto.id);
|
||||||
|
if (existente.isNotEmpty) {
|
||||||
|
existente.first.cantidad++;
|
||||||
|
} else {
|
||||||
|
_carrito.add(ItemPedido(producto: producto, cantidad: 1, precioUnitario: precio));
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void quitarDelCarrito(String productoId) {
|
||||||
|
_carrito.removeWhere((i) => i.producto.id == productoId);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void actualizarCantidad(String productoId, int cantidad) {
|
||||||
|
if (cantidad <= 0) { quitarDelCarrito(productoId); return; }
|
||||||
|
_carrito.firstWhere((i) => i.producto.id == productoId).cantidad = cantidad;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setNotasPedido(String notas) {
|
||||||
|
_notasPedido = notas;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void limpiarCarrito() {
|
||||||
|
_carrito.clear();
|
||||||
|
_clienteSeleccionado = null;
|
||||||
|
_notasPedido = '';
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Pedidos ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
Future<Pedido> confirmarPedido({String? firmaBase64}) async {
|
||||||
|
final id = 'TTC-${(_pedidos.length + 1).toString().padLeft(4, '0')}';
|
||||||
|
final pedido = Pedido(
|
||||||
|
id: id,
|
||||||
|
cliente: _clienteSeleccionado!,
|
||||||
|
items: List.from(_carrito),
|
||||||
|
estado: EstadoPedido.confirmado,
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
notas: _notasPedido,
|
||||||
|
firmaBase64: firmaBase64,
|
||||||
|
);
|
||||||
|
await _db.insertPedido(pedido);
|
||||||
|
_pedidos.insert(0, pedido);
|
||||||
|
_notifService?.notifPedidoConfirmado(id, _clienteSeleccionado!.nombre);
|
||||||
|
limpiarCarrito();
|
||||||
|
notifyListeners();
|
||||||
|
return pedido;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> cambiarEstadoPedido(String pedidoId, EstadoPedido nuevoEstado) async {
|
||||||
|
await _db.updateEstadoPedido(pedidoId, nuevoEstado.label.toLowerCase());
|
||||||
|
final pedido = _pedidos.firstWhere((p) => p.id == pedidoId);
|
||||||
|
pedido.estado = nuevoEstado;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> eliminarPedido(String pedidoId) async {
|
||||||
|
await _db.deletePedido(pedidoId);
|
||||||
|
_pedidos.removeWhere((p) => p.id == pedidoId);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Helpers ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
String _horaDefault() {
|
||||||
|
final now = DateTime.now();
|
||||||
|
final h = now.hour.toString().padLeft(2, '0');
|
||||||
|
final m = ((now.minute ~/ 15 + 1) * 15 % 60).toString().padLeft(2, '0');
|
||||||
|
return '$h:$m';
|
||||||
|
}
|
||||||
|
|
||||||
|
String _horaActual() {
|
||||||
|
final now = DateTime.now();
|
||||||
|
return '${now.hour.toString().padLeft(2, '0')}:${now.minute.toString().padLeft(2, '0')}';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,317 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../models/producto.dart';
|
||||||
|
import '../scanner/scanner_helper.dart';
|
||||||
|
|
||||||
|
class CatalogoScreen extends StatefulWidget {
|
||||||
|
const CatalogoScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CatalogoScreen> createState() => _CatalogoScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CatalogoScreenState extends State<CatalogoScreen> {
|
||||||
|
final _searchCtrl = TextEditingController();
|
||||||
|
String _categoriaSeleccionada = 'Todos';
|
||||||
|
String _query = '';
|
||||||
|
|
||||||
|
final _categorias = ['Todos', 'Redes & Conectividad', 'Telefonía & Móviles', 'Cómputo & Periféricos', 'Seguridad & Vigilancia', 'Servicios'];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_searchCtrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.watch<AppProvider>();
|
||||||
|
final fmt = NumberFormat.currency(locale: 'es_BO', symbol: 'Bs.', decimalDigits: 2);
|
||||||
|
|
||||||
|
final filtrados = provider.productos.where((p) {
|
||||||
|
final matchCat = _categoriaSeleccionada == 'Todos' || p.categoria == _categoriaSeleccionada;
|
||||||
|
final matchQuery = _query.isEmpty ||
|
||||||
|
p.nombre.toLowerCase().contains(_query.toLowerCase()) ||
|
||||||
|
p.sku.toLowerCase().contains(_query.toLowerCase());
|
||||||
|
return matchCat && matchQuery;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Catálogo de Productos', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
actions: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 12),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.shopping_cart_outlined),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
if (provider.cantidadCarrito > 0)
|
||||||
|
Positioned(
|
||||||
|
right: 6,
|
||||||
|
top: 6,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(4),
|
||||||
|
decoration: const BoxDecoration(color: Colors.red, shape: BoxShape.circle),
|
||||||
|
child: Text(
|
||||||
|
'${provider.cantidadCarrito}',
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 9, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
||||||
|
child: TextField(
|
||||||
|
controller: _searchCtrl,
|
||||||
|
onChanged: (v) => setState(() => _query = v),
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Buscar producto o SKU...',
|
||||||
|
hintStyle: const TextStyle(color: Colors.white60),
|
||||||
|
prefixIcon: const Icon(Icons.search, color: Colors.white70),
|
||||||
|
suffixIcon: _query.isNotEmpty
|
||||||
|
? IconButton(
|
||||||
|
icon: const Icon(Icons.clear, color: Colors.white70),
|
||||||
|
onPressed: () {
|
||||||
|
_searchCtrl.clear();
|
||||||
|
setState(() => _query = '');
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: IconButton(
|
||||||
|
tooltip: 'Escanear código',
|
||||||
|
icon: const Icon(Icons.qr_code_scanner, color: Colors.white70),
|
||||||
|
onPressed: () async {
|
||||||
|
final resultado = await abrirScanner(context, titulo: 'Buscar producto');
|
||||||
|
if (resultado != null && mounted) {
|
||||||
|
_searchCtrl.text = resultado;
|
||||||
|
setState(() => _query = resultado);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.white.withOpacity(0.15),
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
borderSide: const BorderSide(color: Colors.white54),
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Categories
|
||||||
|
Container(
|
||||||
|
height: 44,
|
||||||
|
color: Colors.white,
|
||||||
|
child: ListView.builder(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
|
itemCount: _categorias.length,
|
||||||
|
itemBuilder: (context, i) {
|
||||||
|
final cat = _categorias[i];
|
||||||
|
final selected = cat == _categoriaSeleccionada;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 8),
|
||||||
|
child: FilterChip(
|
||||||
|
label: Text(cat),
|
||||||
|
selected: selected,
|
||||||
|
onSelected: (_) => setState(() => _categoriaSeleccionada = cat),
|
||||||
|
selectedColor: AppTheme.primaryColor,
|
||||||
|
checkmarkColor: Colors.white,
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color: selected ? Colors.white : AppTheme.textPrimary,
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: selected ? FontWeight.w600 : FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Count
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'${filtrados.length} productos',
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Grid
|
||||||
|
Expanded(
|
||||||
|
child: GridView.builder(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 80),
|
||||||
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 2,
|
||||||
|
childAspectRatio: 0.72,
|
||||||
|
crossAxisSpacing: 12,
|
||||||
|
mainAxisSpacing: 12,
|
||||||
|
),
|
||||||
|
itemCount: filtrados.length,
|
||||||
|
itemBuilder: (context, i) => _buildProductCard(context, filtrados[i], provider, fmt),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildProductCard(BuildContext context, Producto producto, AppProvider provider, NumberFormat fmt) {
|
||||||
|
final enCarrito = provider.carrito.where((i) => i.producto.id == producto.id);
|
||||||
|
final cantidadEnCarrito = enCarrito.isNotEmpty ? enCarrito.first.cantidad : 0;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.06), blurRadius: 8, offset: const Offset(0, 3))],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Product image placeholder
|
||||||
|
Container(
|
||||||
|
height: 110,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor.withOpacity(0.06),
|
||||||
|
borderRadius: const BorderRadius.vertical(top: Radius.circular(14)),
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Text(producto.emoji, style: const TextStyle(fontSize: 52)),
|
||||||
|
),
|
||||||
|
if (producto.stock < 20)
|
||||||
|
Positioned(
|
||||||
|
top: 8,
|
||||||
|
left: 8,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.dangerColor,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: const Text('Bajo stock', style: TextStyle(color: Colors.white, fontSize: 8, fontWeight: FontWeight.bold)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
producto.nombre,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 12, color: AppTheme.textPrimary),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
'SKU: ${producto.sku}',
|
||||||
|
style: const TextStyle(fontSize: 10, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
fmt.format(producto.precio),
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: AppTheme.primaryColor),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Mayor: ${fmt.format(producto.precioMayorista)}',
|
||||||
|
style: const TextStyle(fontSize: 9, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
cantidadEnCarrito == 0
|
||||||
|
? SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 32,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () => provider.agregarAlCarrito(producto),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.add, size: 16),
|
||||||
|
SizedBox(width: 4),
|
||||||
|
Text('Agregar', style: TextStyle(fontSize: 12)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
_counterBtn(Icons.remove, () => provider.actualizarCantidad(producto.id, cantidadEnCarrito - 1)),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'$cantidadEnCarrito',
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, color: AppTheme.primaryColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_counterBtn(Icons.add, () => provider.agregarAlCarrito(producto)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _counterBtn(IconData icon, VoidCallback onTap) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Icon(icon, size: 16, color: Colors.white),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,369 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../models/cliente.dart';
|
||||||
|
|
||||||
|
class ClienteFormScreen extends StatefulWidget {
|
||||||
|
final Cliente? clienteEditar;
|
||||||
|
|
||||||
|
const ClienteFormScreen({Key? key, this.clienteEditar}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ClienteFormScreen> createState() => _ClienteFormScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ClienteFormScreenState extends State<ClienteFormScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
final _nombreCtrl = TextEditingController();
|
||||||
|
final _razonSocialCtrl = TextEditingController();
|
||||||
|
final _nitCtrl = TextEditingController();
|
||||||
|
final _telefonoCtrl = TextEditingController();
|
||||||
|
final _direccionCtrl = TextEditingController();
|
||||||
|
final _referenciaCtrl = TextEditingController();
|
||||||
|
|
||||||
|
String _categoria = 'Minorista';
|
||||||
|
bool _agregarARuta = true;
|
||||||
|
bool _guardando = false;
|
||||||
|
|
||||||
|
final _categorias = ['Minorista', 'Mayorista', 'Distribuidor', 'Empresa', 'Institución', 'Gobierno'];
|
||||||
|
|
||||||
|
bool get esEdicion => widget.clienteEditar != null;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (esEdicion) {
|
||||||
|
final c = widget.clienteEditar!;
|
||||||
|
_nombreCtrl.text = c.nombre;
|
||||||
|
_razonSocialCtrl.text = c.razonSocial;
|
||||||
|
_nitCtrl.text = c.nit;
|
||||||
|
_telefonoCtrl.text = c.telefono;
|
||||||
|
_direccionCtrl.text = c.direccion;
|
||||||
|
_categoria = c.categoria;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_nombreCtrl.dispose();
|
||||||
|
_razonSocialCtrl.dispose();
|
||||||
|
_nitCtrl.dispose();
|
||||||
|
_telefonoCtrl.dispose();
|
||||||
|
_direccionCtrl.dispose();
|
||||||
|
_referenciaCtrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(
|
||||||
|
esEdicion ? 'Editar cliente' : 'Nuevo punto de distribución',
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: ListView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
children: [
|
||||||
|
_buildSectionHeader(Icons.store, 'Datos del negocio'),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_buildCard(children: [
|
||||||
|
_buildField(
|
||||||
|
controller: _nombreCtrl,
|
||||||
|
label: 'Nombre comercial *',
|
||||||
|
hint: 'Ej. Tienda Don Pepe',
|
||||||
|
icon: Icons.storefront_outlined,
|
||||||
|
validator: _required,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
_buildField(
|
||||||
|
controller: _razonSocialCtrl,
|
||||||
|
label: 'Razón social',
|
||||||
|
hint: 'Ej. José García S.R.L.',
|
||||||
|
icon: Icons.business_outlined,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
_buildField(
|
||||||
|
controller: _nitCtrl,
|
||||||
|
label: 'NIT / CI',
|
||||||
|
hint: 'Número de identificación tributaria',
|
||||||
|
icon: Icons.badge_outlined,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildSectionHeader(Icons.category_outlined, 'Categoría del cliente'),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_buildCard(children: [
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: _categorias.map((cat) {
|
||||||
|
final selected = _categoria == cat;
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () => setState(() => _categoria = cat),
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: const Duration(milliseconds: 180),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: selected ? AppTheme.primaryColor : const Color(0xFFF1F5F9),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(
|
||||||
|
color: selected ? AppTheme.primaryColor : const Color(0xFFCBD5E1),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
_iconForCategoria(cat),
|
||||||
|
size: 16,
|
||||||
|
color: selected ? Colors.white : AppTheme.textSecondary,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
cat,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: selected ? FontWeight.w600 : FontWeight.normal,
|
||||||
|
color: selected ? Colors.white : AppTheme.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildSectionHeader(Icons.contact_phone_outlined, 'Contacto'),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_buildCard(children: [
|
||||||
|
_buildField(
|
||||||
|
controller: _telefonoCtrl,
|
||||||
|
label: 'Teléfono / Celular *',
|
||||||
|
hint: 'Ej. +591 70000000',
|
||||||
|
icon: Icons.phone_outlined,
|
||||||
|
keyboardType: TextInputType.phone,
|
||||||
|
validator: _required,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildSectionHeader(Icons.location_on_outlined, 'Ubicación'),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_buildCard(children: [
|
||||||
|
_buildField(
|
||||||
|
controller: _direccionCtrl,
|
||||||
|
label: 'Dirección *',
|
||||||
|
hint: 'Calle, número, zona o barrio',
|
||||||
|
icon: Icons.home_outlined,
|
||||||
|
validator: _required,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
_buildField(
|
||||||
|
controller: _referenciaCtrl,
|
||||||
|
label: 'Referencia',
|
||||||
|
hint: 'Ej. Frente al parque, edificio azul...',
|
||||||
|
icon: Icons.signpost_outlined,
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
// Simulated GPS pin button
|
||||||
|
OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.my_location, size: 18),
|
||||||
|
label: const Text('Usar mi ubicación actual'),
|
||||||
|
onPressed: () {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('GPS: función disponible con permisos de ubicación'),
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
minimumSize: const Size(double.infinity, 44),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
if (!esEdicion) ...[
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildSectionHeader(Icons.route_outlined, 'Ruta del día'),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_buildCard(children: [
|
||||||
|
SwitchListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: const Text(
|
||||||
|
'Agregar a la ruta de hoy',
|
||||||
|
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
subtitle: const Text(
|
||||||
|
'El punto se añade como parada pendiente',
|
||||||
|
style: TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
value: _agregarARuta,
|
||||||
|
onChanged: (v) => setState(() => _agregarARuta = v),
|
||||||
|
activeColor: AppTheme.primaryColor,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
|
||||||
|
const SizedBox(height: 28),
|
||||||
|
_buildSubmitButton(context),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSectionHeader(IconData icon, String titulo) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 16, color: AppTheme.primaryColor),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
titulo,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
letterSpacing: 0.3,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCard({required List<Widget> children}) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 8, offset: const Offset(0, 2)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: children,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildField({
|
||||||
|
required TextEditingController controller,
|
||||||
|
required String label,
|
||||||
|
required String hint,
|
||||||
|
required IconData icon,
|
||||||
|
TextInputType keyboardType = TextInputType.text,
|
||||||
|
int maxLines = 1,
|
||||||
|
String? Function(String?)? validator,
|
||||||
|
}) {
|
||||||
|
return TextFormField(
|
||||||
|
controller: controller,
|
||||||
|
keyboardType: keyboardType,
|
||||||
|
maxLines: maxLines,
|
||||||
|
validator: validator,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: label,
|
||||||
|
hintText: hint,
|
||||||
|
prefixIcon: Icon(icon, size: 20),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSubmitButton(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 52,
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
icon: _guardando
|
||||||
|
? const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2.5),
|
||||||
|
)
|
||||||
|
: Icon(esEdicion ? Icons.save_outlined : Icons.add_location_alt_outlined, size: 22),
|
||||||
|
label: Text(
|
||||||
|
_guardando
|
||||||
|
? 'Guardando...'
|
||||||
|
: esEdicion
|
||||||
|
? 'Guardar cambios'
|
||||||
|
: 'Registrar punto de distribución',
|
||||||
|
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
onPressed: _guardando ? null : () => _submit(context),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _submit(BuildContext context) async {
|
||||||
|
if (!_formKey.currentState!.validate()) return;
|
||||||
|
|
||||||
|
setState(() => _guardando = true);
|
||||||
|
await Future.delayed(const Duration(milliseconds: 600));
|
||||||
|
|
||||||
|
final provider = context.read<AppProvider>();
|
||||||
|
|
||||||
|
final cliente = Cliente(
|
||||||
|
id: 'c_${DateTime.now().millisecondsSinceEpoch}',
|
||||||
|
nombre: _nombreCtrl.text.trim(),
|
||||||
|
razonSocial: _razonSocialCtrl.text.trim().isEmpty
|
||||||
|
? _nombreCtrl.text.trim()
|
||||||
|
: _razonSocialCtrl.text.trim(),
|
||||||
|
nit: _nitCtrl.text.trim().isEmpty ? '—' : _nitCtrl.text.trim(),
|
||||||
|
telefono: _telefonoCtrl.text.trim(),
|
||||||
|
direccion: _direccionCtrl.text.trim(),
|
||||||
|
categoria: _categoria,
|
||||||
|
lat: -16.5,
|
||||||
|
lng: -68.1,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (esEdicion) {
|
||||||
|
provider.actualizarCliente(cliente);
|
||||||
|
} else {
|
||||||
|
provider.agregarCliente(cliente, agregarARuta: _agregarARuta);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.pop(context, cliente);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(
|
||||||
|
esEdicion
|
||||||
|
? '✓ ${cliente.nombre} actualizado'
|
||||||
|
: '✓ ${cliente.nombre} registrado${_agregarARuta ? ' y agregado a la ruta' : ''}',
|
||||||
|
),
|
||||||
|
backgroundColor: AppTheme.successColor,
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String? _required(String? v) =>
|
||||||
|
(v == null || v.trim().isEmpty) ? 'Este campo es obligatorio' : null;
|
||||||
|
|
||||||
|
IconData _iconForCategoria(String cat) {
|
||||||
|
switch (cat) {
|
||||||
|
case 'Mayorista': return Icons.warehouse_outlined;
|
||||||
|
case 'Distribuidor': return Icons.local_shipping_outlined;
|
||||||
|
case 'Empresa': return Icons.business_outlined;
|
||||||
|
case 'Institución': return Icons.school_outlined;
|
||||||
|
case 'Gobierno': return Icons.account_balance_outlined;
|
||||||
|
default: return Icons.store_outlined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,299 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../../models/cliente.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
|
||||||
|
const int _kMaxResultados = 50;
|
||||||
|
|
||||||
|
/// Pantalla de búsqueda de clientes. Retorna el [Cliente] seleccionado o null.
|
||||||
|
///
|
||||||
|
/// Uso:
|
||||||
|
/// ```dart
|
||||||
|
/// final cliente = await Navigator.push<Cliente>(
|
||||||
|
/// context,
|
||||||
|
/// MaterialPageRoute(builder: (_) => ClienteSelectorScreen(clientes: provider.clientes)),
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
class ClienteSelectorScreen extends StatefulWidget {
|
||||||
|
final List<Cliente> clientes;
|
||||||
|
final String titulo;
|
||||||
|
|
||||||
|
const ClienteSelectorScreen({
|
||||||
|
Key? key,
|
||||||
|
required this.clientes,
|
||||||
|
this.titulo = 'Seleccionar cliente',
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ClienteSelectorScreen> createState() => _ClienteSelectorScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ClienteSelectorScreenState extends State<ClienteSelectorScreen> {
|
||||||
|
final _searchCtrl = TextEditingController();
|
||||||
|
final _focusNode = FocusNode();
|
||||||
|
Timer? _debounce;
|
||||||
|
|
||||||
|
String _query = '';
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
// Autofocus al abrir
|
||||||
|
WidgetsBinding.instance!.addPostFrameCallback((_) => _focusNode.requestFocus());
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_debounce?.cancel();
|
||||||
|
_searchCtrl.dispose();
|
||||||
|
_focusNode.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onSearchChanged(String value) {
|
||||||
|
_debounce?.cancel();
|
||||||
|
_debounce = Timer(const Duration(milliseconds: 250), () {
|
||||||
|
setState(() => _query = value.trim());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Cliente> get _filtrados {
|
||||||
|
if (_query.isEmpty) return const [];
|
||||||
|
final q = _query.toLowerCase();
|
||||||
|
return widget.clientes.where((c) {
|
||||||
|
return c.nombre.toLowerCase().contains(q) ||
|
||||||
|
c.nit.toLowerCase().contains(q) ||
|
||||||
|
c.direccion.toLowerCase().contains(q) ||
|
||||||
|
c.categoria.toLowerCase().contains(q);
|
||||||
|
}).take(_kMaxResultados + 1).toList(); // +1 para detectar si hay más
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final resultados = _filtrados;
|
||||||
|
final hayMas = resultados.length > _kMaxResultados;
|
||||||
|
final visibles = hayMas ? resultados.take(_kMaxResultados).toList() : resultados;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
titleSpacing: 0,
|
||||||
|
title: TextField(
|
||||||
|
controller: _searchCtrl,
|
||||||
|
focusNode: _focusNode,
|
||||||
|
onChanged: _onSearchChanged,
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 15),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Buscar por nombre, NIT o dirección...',
|
||||||
|
hintStyle: TextStyle(color: Colors.white.withOpacity(0.55), fontSize: 14),
|
||||||
|
border: InputBorder.none,
|
||||||
|
prefixIcon: const Icon(Icons.search, color: Colors.white70, size: 22),
|
||||||
|
suffixIcon: _searchCtrl.text.isNotEmpty
|
||||||
|
? IconButton(
|
||||||
|
icon: const Icon(Icons.clear, color: Colors.white70, size: 20),
|
||||||
|
onPressed: () {
|
||||||
|
_searchCtrl.clear();
|
||||||
|
setState(() => _query = '');
|
||||||
|
_focusNode.requestFocus();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: _buildBody(visibles, hayMas),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBody(List<Cliente> visibles, bool hayMas) {
|
||||||
|
if (_query.isEmpty) {
|
||||||
|
return _buildEstadoInicial();
|
||||||
|
}
|
||||||
|
if (visibles.isEmpty) {
|
||||||
|
return _buildSinResultados();
|
||||||
|
}
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
_buildContador(visibles.length, hayMas),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
|
||||||
|
itemCount: visibles.length + (hayMas ? 1 : 0),
|
||||||
|
itemBuilder: (ctx, i) {
|
||||||
|
if (i == visibles.length) return _buildMasResultados();
|
||||||
|
return _buildClienteTile(visibles[i]);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEstadoInicial() {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.search, size: 64, color: Colors.grey.shade300),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'${widget.clientes.length} clientes disponibles',
|
||||||
|
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
const Text(
|
||||||
|
'Escribe para buscar',
|
||||||
|
style: TextStyle(fontSize: 13, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSinResultados() {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.store_outlined, size: 56, color: Colors.grey.shade300),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
Text(
|
||||||
|
'Sin resultados para "$_query"',
|
||||||
|
style: const TextStyle(fontSize: 14, color: AppTheme.textSecondary),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
const Text(
|
||||||
|
'Prueba con nombre, NIT o dirección',
|
||||||
|
style: TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildContador(int cantidad, bool hayMas) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 10, 16, 4),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
hayMas
|
||||||
|
? 'Mostrando $_kMaxResultados de más resultados — refina la búsqueda'
|
||||||
|
: '$cantidad resultado${cantidad == 1 ? '' : 's'}',
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildClienteTile(Cliente c) {
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.only(bottom: 6),
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
side: const BorderSide(color: Color(0xFFE2E8F0)),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
onTap: () => Navigator.pop(context, c),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 20,
|
||||||
|
backgroundColor: AppTheme.primaryColor.withOpacity(0.1),
|
||||||
|
child: const Icon(Icons.store, size: 20, color: AppTheme.primaryColor),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildTextoResaltado(c.nombre, _query,
|
||||||
|
const TextStyle(fontWeight: FontWeight.w600, fontSize: 14, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
c.direccion,
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
_buildChip(c.categoria),
|
||||||
|
if (c.nit.isNotEmpty) ...[
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text('NIT ${c.nit}',
|
||||||
|
style: const TextStyle(fontSize: 10, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Icon(Icons.chevron_right, color: AppTheme.textSecondary, size: 20),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMasResultados() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'Hay más resultados — refina la búsqueda para verlos',
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.grey.shade500),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildChip(String texto) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor.withOpacity(0.08),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: Text(texto, style: const TextStyle(fontSize: 10, color: AppTheme.primaryColor, fontWeight: FontWeight.w500)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Resalta el texto que coincide con la búsqueda en negrita
|
||||||
|
Widget _buildTextoResaltado(String texto, String query, TextStyle baseStyle) {
|
||||||
|
if (query.isEmpty) return Text(texto, style: baseStyle, maxLines: 1, overflow: TextOverflow.ellipsis);
|
||||||
|
final lower = texto.toLowerCase();
|
||||||
|
final idx = lower.indexOf(query.toLowerCase());
|
||||||
|
if (idx < 0) return Text(texto, style: baseStyle, maxLines: 1, overflow: TextOverflow.ellipsis);
|
||||||
|
|
||||||
|
return RichText(
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
text: TextSpan(
|
||||||
|
style: baseStyle,
|
||||||
|
children: [
|
||||||
|
if (idx > 0) TextSpan(text: texto.substring(0, idx)),
|
||||||
|
TextSpan(
|
||||||
|
text: texto.substring(idx, idx + query.length),
|
||||||
|
style: baseStyle.copyWith(
|
||||||
|
backgroundColor: AppTheme.primaryColor.withOpacity(0.18),
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (idx + query.length < texto.length)
|
||||||
|
TextSpan(text: texto.substring(idx + query.length)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,322 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../widgets/signature_pad.dart';
|
||||||
|
|
||||||
|
class FirmaScreen extends StatefulWidget {
|
||||||
|
const FirmaScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FirmaScreen> createState() => _FirmaScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FirmaScreenState extends State<FirmaScreen> {
|
||||||
|
final _padKey = GlobalKey<SignaturePadState>();
|
||||||
|
bool _firmado = false;
|
||||||
|
bool _guardando = false;
|
||||||
|
|
||||||
|
final _fmt = NumberFormat.currency(locale: 'es_BO', symbol: 'Bs.', decimalDigits: 2);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.watch<AppProvider>();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Firma del Cliente', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_buildResumenPedido(provider),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_buildSignatureArea(context),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_buildBottomBar(context, provider),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildResumenPedido(AppProvider provider) {
|
||||||
|
final cliente = provider.clienteSeleccionado;
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.all(16),
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
colors: [Color(0xFF1E3A8A), Color(0xFF2563EB)],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.receipt_long, color: Colors.white70, size: 16),
|
||||||
|
SizedBox(width: 6),
|
||||||
|
Text('Resumen del pedido', style: TextStyle(color: Colors.white70, fontSize: 13)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Cliente:', style: TextStyle(color: Colors.white60, fontSize: 11)),
|
||||||
|
Text(
|
||||||
|
cliente?.nombre ?? '—',
|
||||||
|
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
const Text('Dirección:', style: TextStyle(color: Colors.white60, fontSize: 11)),
|
||||||
|
Text(
|
||||||
|
cliente?.direccion ?? '—',
|
||||||
|
style: const TextStyle(color: Colors.white70, fontSize: 12),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
const Text('Total:', style: TextStyle(color: Colors.white70, fontSize: 13)),
|
||||||
|
Text(
|
||||||
|
_fmt.format(provider.totalCarrito),
|
||||||
|
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 24),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'${provider.cantidadCarrito} unidades',
|
||||||
|
style: const TextStyle(color: Colors.white60, fontSize: 11),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Divider(color: Colors.white24, height: 20),
|
||||||
|
Text(
|
||||||
|
'${provider.carrito.length} producto(s): '
|
||||||
|
'${provider.carrito.map((i) => i.producto.nombre.split(' ').first).take(3).join(', ')}'
|
||||||
|
'${provider.carrito.length > 3 ? '...' : ''}',
|
||||||
|
style: const TextStyle(color: Colors.white60, fontSize: 11),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSignatureArea(BuildContext context) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: const [
|
||||||
|
Text('Firma de conformidad', style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
Text('El cliente firma confirmando el pedido', style: TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TextButton.icon(
|
||||||
|
icon: const Icon(Icons.refresh, size: 16),
|
||||||
|
label: const Text('Limpiar'),
|
||||||
|
onPressed: () {
|
||||||
|
_padKey.currentState?.clear();
|
||||||
|
setState(() => _firmado = false);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Container(
|
||||||
|
height: 220,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.08), blurRadius: 10, offset: const Offset(0, 4))],
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
SignaturePad(
|
||||||
|
key: _padKey,
|
||||||
|
onChanged: (strokes) {
|
||||||
|
setState(() => _firmado = strokes.isNotEmpty);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (!_firmado)
|
||||||
|
Positioned.fill(
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.draw_outlined, size: 40, color: Colors.grey.shade300),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Firmar aquí',
|
||||||
|
style: TextStyle(fontSize: 16, color: Colors.grey.shade400, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Divider(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: const [
|
||||||
|
Text('Nombre del firmante:', style: TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
Text('Responsable de recepción', style: TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_firmado)
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(top: 8),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.successColor.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: AppTheme.successColor.withOpacity(0.3)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.check_circle_outline, color: AppTheme.successColor, size: 16),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text('Firma registrada', style: TextStyle(color: AppTheme.successColor, fontSize: 12, fontWeight: FontWeight.w600)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBottomBar(BuildContext context, AppProvider provider) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 28),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 8, offset: Offset(0, -2))],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: OutlinedButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('Volver al pedido'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
icon: _guardando
|
||||||
|
? const SizedBox(width: 18, height: 18, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||||
|
: const Icon(Icons.check_circle_outline, size: 22),
|
||||||
|
label: Text(_guardando ? 'Guardando...' : 'Confirmar pedido',
|
||||||
|
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600)),
|
||||||
|
onPressed: (!_firmado || _guardando)
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
setState(() => _guardando = true);
|
||||||
|
final pedido = await provider.confirmarPedido(firmaBase64: 'signed');
|
||||||
|
if (mounted) {
|
||||||
|
_showSuccess(context, pedido.id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
if (!_firmado)
|
||||||
|
const Text(
|
||||||
|
'El cliente debe firmar para confirmar el pedido',
|
||||||
|
style: TextStyle(fontSize: 11, color: AppTheme.textSecondary),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showSuccess(BuildContext context, String pedidoId) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (_) => AlertDialog(
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 72,
|
||||||
|
height: 72,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Color(0xFFDCFCE7),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.check, color: AppTheme.successColor, size: 40),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
const Text('¡Pedido confirmado!',
|
||||||
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'$pedidoId ha sido registrado correctamente.',
|
||||||
|
style: const TextStyle(color: AppTheme.textSecondary, fontSize: 13),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context)
|
||||||
|
..pop()
|
||||||
|
..pop()
|
||||||
|
..pop();
|
||||||
|
},
|
||||||
|
child: const Text('Volver al inicio'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,539 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../services/notification_service.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../widgets/stat_card.dart';
|
||||||
|
import '../../models/pedido.dart';
|
||||||
|
import '../notificaciones/notificaciones_screen.dart';
|
||||||
|
|
||||||
|
class HomeScreen extends StatelessWidget {
|
||||||
|
const HomeScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.watch<AppProvider>();
|
||||||
|
final notifService = context.watch<NotificationService>();
|
||||||
|
final fmt = NumberFormat.currency(locale: 'es_BO', symbol: 'Bs.', decimalDigits: 2);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
body: RefreshIndicator(
|
||||||
|
onRefresh: () async => await Future.delayed(const Duration(milliseconds: 600)),
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
_buildSliverAppBar(context, provider, notifService),
|
||||||
|
SliverPadding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
sliver: SliverList(
|
||||||
|
delegate: SliverChildListDelegate([
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_buildStatsGrid(context, provider, fmt),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildRutaCard(context, provider),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildRecentOrders(context, provider, fmt),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildQuickActions(context, notifService),
|
||||||
|
const SizedBox(height: 80),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSliverAppBar(
|
||||||
|
BuildContext context,
|
||||||
|
AppProvider provider,
|
||||||
|
NotificationService notifService,
|
||||||
|
) {
|
||||||
|
final hour = DateTime.now().hour;
|
||||||
|
final greeting = hour < 12 ? 'Buenos días' : hour < 18 ? 'Buenas tardes' : 'Buenas noches';
|
||||||
|
final dateStr = DateFormat('EEEE, d \'de\' MMMM', 'es').format(DateTime.now());
|
||||||
|
final unread = notifService.unreadCount;
|
||||||
|
|
||||||
|
return SliverAppBar(
|
||||||
|
expandedHeight: 160,
|
||||||
|
floating: false,
|
||||||
|
pinned: true,
|
||||||
|
backgroundColor: AppTheme.primaryColor,
|
||||||
|
actions: [
|
||||||
|
Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.notifications_outlined, color: Colors.white, size: 26),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const NotificacionesScreen()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (unread > 0)
|
||||||
|
Positioned(
|
||||||
|
top: 10,
|
||||||
|
right: 10,
|
||||||
|
child: Container(
|
||||||
|
width: 17,
|
||||||
|
height: 17,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFEF4444),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(color: AppTheme.primaryColor, width: 1.5),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
unread > 9 ? '9+' : '$unread',
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 9,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
height: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
|
background: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [Color(0xFF1E3A8A), Color(0xFF2563EB)],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: SafeArea(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(20, 16, 60, 0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 22,
|
||||||
|
backgroundColor: Colors.white.withOpacity(0.2),
|
||||||
|
child: Text(
|
||||||
|
provider.vendedor.avatarInitials,
|
||||||
|
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'$greeting,',
|
||||||
|
style: const TextStyle(color: Colors.white70, fontSize: 13),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
provider.vendedor.nombre,
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 17, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.calendar_today, color: Colors.white60, size: 14),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(
|
||||||
|
dateStr,
|
||||||
|
style: const TextStyle(color: Colors.white70, fontSize: 13),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.location_on, color: Colors.white, size: 14),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
provider.vendedor.zona,
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
greeting,
|
||||||
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
titlePadding: const EdgeInsets.only(left: 16, bottom: 12),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildStatsGrid(BuildContext context, AppProvider provider, NumberFormat fmt) {
|
||||||
|
final ruta = provider.ruta;
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Resumen del día',
|
||||||
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
GridView.count(
|
||||||
|
crossAxisCount: 2,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
crossAxisSpacing: 12,
|
||||||
|
mainAxisSpacing: 12,
|
||||||
|
childAspectRatio: 1.5,
|
||||||
|
children: [
|
||||||
|
StatCard(
|
||||||
|
titulo: 'Pedidos hoy',
|
||||||
|
valor: '${provider.pedidosHoy}',
|
||||||
|
subtitulo: 'confirmados',
|
||||||
|
icono: Icons.receipt_long,
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
),
|
||||||
|
StatCard(
|
||||||
|
titulo: 'Ventas del día',
|
||||||
|
valor: fmt.format(provider.ventasTotalesHoy),
|
||||||
|
subtitulo: 'total acumulado',
|
||||||
|
icono: Icons.attach_money,
|
||||||
|
color: AppTheme.successColor,
|
||||||
|
),
|
||||||
|
StatCard(
|
||||||
|
titulo: 'Clientes visitados',
|
||||||
|
valor: '${ruta.visitadas}/${ruta.paradas.length}',
|
||||||
|
subtitulo: 'en la ruta',
|
||||||
|
icono: Icons.store,
|
||||||
|
color: AppTheme.accentColor,
|
||||||
|
),
|
||||||
|
StatCard(
|
||||||
|
titulo: 'Paradas restantes',
|
||||||
|
valor: '${ruta.pendientes}',
|
||||||
|
subtitulo: 'por visitar',
|
||||||
|
icono: Icons.flag_outlined,
|
||||||
|
color: AppTheme.warningColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildRutaCard(BuildContext context, AppProvider provider) {
|
||||||
|
final ruta = provider.ruta;
|
||||||
|
final proxima = ruta.paradas.where((p) => p.estado.name == 'pendiente').isNotEmpty
|
||||||
|
? ruta.paradas.firstWhere((p) => p.estado.name == 'pendiente')
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
colors: [Color(0xFF0F172A), Color(0xFF1E3A8A)],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.route, color: Colors.white, size: 20),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
ruta.nombre,
|
||||||
|
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 15),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.15),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'${ruta.visitadas}/${ruta.paradas.length} paradas',
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
child: LinearProgressIndicator(
|
||||||
|
value: ruta.paradas.isEmpty ? 0 : ruta.visitadas / ruta.paradas.length,
|
||||||
|
backgroundColor: Colors.white.withOpacity(0.2),
|
||||||
|
valueColor: const AlwaysStoppedAnimation<Color>(Color(0xFF34D399)),
|
||||||
|
minHeight: 6,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (proxima != null) ...[
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.navigation, color: Color(0xFF34D399), size: 16),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
const Text('Próxima parada:', style: TextStyle(color: Colors.white60, fontSize: 12)),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
proxima.cliente.nombre,
|
||||||
|
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600, fontSize: 13),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
proxima.horaEstimada,
|
||||||
|
style: const TextStyle(color: Color(0xFFFBBF24), fontSize: 13, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildRecentOrders(BuildContext context, AppProvider provider, NumberFormat fmt) {
|
||||||
|
final recientes = provider.pedidos.take(3).toList();
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text('Pedidos recientes',
|
||||||
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {},
|
||||||
|
child: const Text('Ver todos'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
...recientes.map((pedido) => _buildOrderTile(context, pedido, fmt)).toList(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildOrderTile(BuildContext context, Pedido pedido, NumberFormat fmt) {
|
||||||
|
final estadoColor = AppTheme.estadoColor(pedido.estado.label);
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 6, offset: const Offset(0, 2)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: estadoColor.withOpacity(0.12),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Icon(Icons.receipt_outlined, color: estadoColor, size: 20),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(pedido.id,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: AppTheme.textPrimary)),
|
||||||
|
Text(pedido.cliente.nombre,
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(fmt.format(pedido.total),
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: estadoColor.withOpacity(0.12),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
pedido.estado.label,
|
||||||
|
style: TextStyle(fontSize: 10, color: estadoColor, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildQuickActions(BuildContext context, NotificationService notifService) {
|
||||||
|
final staticActions = [
|
||||||
|
{'icon': Icons.add_shopping_cart, 'label': 'Nuevo\nPedido', 'color': AppTheme.primaryColor},
|
||||||
|
{'icon': Icons.map_outlined, 'label': 'Ver\nRuta', 'color': AppTheme.successColor},
|
||||||
|
{'icon': Icons.inventory_2_outlined, 'label': 'Catálogo', 'color': AppTheme.accentColor},
|
||||||
|
];
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Acciones rápidas',
|
||||||
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
...staticActions.map((a) {
|
||||||
|
final color = a['color'] as Color;
|
||||||
|
return Expanded(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(color: color.withOpacity(0.1), blurRadius: 8, offset: const Offset(0, 3)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Icon(a['icon'] as IconData, color: color, size: 26),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text(
|
||||||
|
a['label'] as String,
|
||||||
|
style: TextStyle(fontSize: 11, color: color, fontWeight: FontWeight.w600),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
Expanded(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => notifService.dispararDemo(),
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: const Color(0xFF7C3AED).withOpacity(0.15),
|
||||||
|
blurRadius: 8,
|
||||||
|
offset: const Offset(0, 3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.notifications_active, color: Color(0xFF7C3AED), size: 26),
|
||||||
|
SizedBox(height: 6),
|
||||||
|
Text(
|
||||||
|
'Demo\nNotif.',
|
||||||
|
style: TextStyle(fontSize: 11, color: Color(0xFF7C3AED), fontWeight: FontWeight.w600),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_buildNotifDemoCard(context, notifService),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildNotifDemoCard(BuildContext context, NotificationService notifService) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
colors: [Color(0xFF4C1D95), Color(0xFF7C3AED)],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 44,
|
||||||
|
height: 44,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.15),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.notifications_active, color: Colors.white, size: 22),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: const [
|
||||||
|
Text(
|
||||||
|
'Demo de notificaciones',
|
||||||
|
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14),
|
||||||
|
),
|
||||||
|
SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
'Pulsa para disparar 5 notificaciones de muestra con banner animado',
|
||||||
|
style: TextStyle(color: Colors.white70, fontSize: 11),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () => notifService.dispararDemo(),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
primary: Colors.white,
|
||||||
|
onPrimary: const Color(0xFF7C3AED),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||||
|
elevation: 0,
|
||||||
|
),
|
||||||
|
child: const Text('Probar', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 13)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
|
||||||
|
class LoginScreen extends StatefulWidget {
|
||||||
|
const LoginScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LoginScreen> createState() => _LoginScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoginScreenState extends State<LoginScreen> {
|
||||||
|
final _emailCtrl = TextEditingController(text: 'admin@telcotronics.com');
|
||||||
|
final _passCtrl = TextEditingController(text: 'Microbot%');
|
||||||
|
bool _obscure = true;
|
||||||
|
bool _loading = false;
|
||||||
|
String? _error;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_emailCtrl.dispose();
|
||||||
|
_passCtrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _login() async {
|
||||||
|
setState(() { _loading = true; _error = null; });
|
||||||
|
final ok = await context.read<AppProvider>().login(
|
||||||
|
_emailCtrl.text.trim(), _passCtrl.text);
|
||||||
|
if (!ok && mounted) {
|
||||||
|
setState(() {
|
||||||
|
_loading = false;
|
||||||
|
_error = context.read<AppProvider>().loginError;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [Color(0xFF1E3A8A), Color(0xFF1E40AF), Color(0xFF2563EB)],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: SafeArea(
|
||||||
|
child: Center(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 28),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_buildLogo(),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
_buildCard(),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
_buildVersion(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildLogo() {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 96,
|
||||||
|
height: 96,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(24),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.25),
|
||||||
|
blurRadius: 20,
|
||||||
|
offset: const Offset(0, 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(24),
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/icon/icon.png',
|
||||||
|
width: 96,
|
||||||
|
height: 96,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
const Text(
|
||||||
|
'Agente Ventas',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 32,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
letterSpacing: 1.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
'by SIGMAC',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: Colors.white.withOpacity(0.65),
|
||||||
|
letterSpacing: 2.0,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Text(
|
||||||
|
'Gestión de rutas y pedidos de campo',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: Colors.white.withOpacity(0.8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCard() {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(28),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.2),
|
||||||
|
blurRadius: 20,
|
||||||
|
offset: const Offset(0, 8),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Iniciar sesión',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppTheme.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
const Text(
|
||||||
|
'Ingresa tus credenciales para continuar',
|
||||||
|
style: TextStyle(fontSize: 13, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
TextField(
|
||||||
|
controller: _emailCtrl,
|
||||||
|
keyboardType: TextInputType.emailAddress,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Correo electrónico',
|
||||||
|
prefixIcon: Icon(Icons.email_outlined),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
TextField(
|
||||||
|
controller: _passCtrl,
|
||||||
|
obscureText: _obscure,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: 'Contraseña',
|
||||||
|
prefixIcon: const Icon(Icons.lock_outline),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(_obscure ? Icons.visibility_outlined : Icons.visibility_off_outlined),
|
||||||
|
onPressed: () => setState(() => _obscure = !_obscure),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () {},
|
||||||
|
child: const Text('¿Olvidaste tu contraseña?'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_error != null) ...[
|
||||||
|
Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.dangerColor.withOpacity(0.08),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: AppTheme.dangerColor.withOpacity(0.3)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.error_outline, color: AppTheme.dangerColor, size: 16),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
_error!,
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.dangerColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
],
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 50,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: _loading ? null : _login,
|
||||||
|
child: _loading
|
||||||
|
? const SizedBox(
|
||||||
|
width: 22,
|
||||||
|
height: 22,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2.5,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.login, size: 20),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text('Ingresar', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildVersion() {
|
||||||
|
return Text(
|
||||||
|
'v1.0.0 • SIGMAC • Telcotronics',
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.6)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
import 'home/home_screen.dart';
|
||||||
|
import 'rutas/rutas_screen.dart';
|
||||||
|
import 'pedidos/pedidos_screen.dart';
|
||||||
|
import 'catalogo/catalogo_screen.dart';
|
||||||
|
import 'perfil/perfil_screen.dart';
|
||||||
|
|
||||||
|
class MainShell extends StatefulWidget {
|
||||||
|
const MainShell({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MainShell> createState() => _MainShellState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MainShellState extends State<MainShell> {
|
||||||
|
int _currentIndex = 0;
|
||||||
|
|
||||||
|
final _screens = const [
|
||||||
|
HomeScreen(),
|
||||||
|
RutasScreen(),
|
||||||
|
PedidosScreen(),
|
||||||
|
CatalogoScreen(),
|
||||||
|
PerfilScreen(),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: IndexedStack(
|
||||||
|
index: _currentIndex,
|
||||||
|
children: _screens,
|
||||||
|
),
|
||||||
|
bottomNavigationBar: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10, offset: Offset(0, -2))],
|
||||||
|
),
|
||||||
|
child: BottomNavigationBar(
|
||||||
|
currentIndex: _currentIndex,
|
||||||
|
onTap: (i) => setState(() => _currentIndex = i),
|
||||||
|
type: BottomNavigationBarType.fixed,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
selectedItemColor: AppTheme.primaryColor,
|
||||||
|
unselectedItemColor: const Color(0xFF94A3B8),
|
||||||
|
selectedFontSize: 11,
|
||||||
|
unselectedFontSize: 11,
|
||||||
|
items: const [
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(Icons.home_outlined),
|
||||||
|
activeIcon: Icon(Icons.home_rounded),
|
||||||
|
label: 'Inicio',
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(Icons.route_outlined),
|
||||||
|
activeIcon: Icon(Icons.route_rounded),
|
||||||
|
label: 'Mi Ruta',
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(Icons.receipt_long_outlined),
|
||||||
|
activeIcon: Icon(Icons.receipt_long_rounded),
|
||||||
|
label: 'Pedidos',
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(Icons.inventory_2_outlined),
|
||||||
|
activeIcon: Icon(Icons.inventory_2_rounded),
|
||||||
|
label: 'Catálogo',
|
||||||
|
),
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: Icon(Icons.person_outline_rounded),
|
||||||
|
activeIcon: Icon(Icons.person_rounded),
|
||||||
|
label: 'Perfil',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../services/notification_service.dart';
|
||||||
|
import '../../models/notificacion.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
|
||||||
|
class NotificacionesScreen extends StatelessWidget {
|
||||||
|
const NotificacionesScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<NotificationService>(
|
||||||
|
builder: (context, service, _) {
|
||||||
|
final notifs = service.notifications;
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
body: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
_buildAppBar(context, service),
|
||||||
|
if (notifs.isEmpty)
|
||||||
|
_buildEmptyState()
|
||||||
|
else
|
||||||
|
_buildList(context, service, notifs),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAppBar(BuildContext context, NotificationService service) {
|
||||||
|
return SliverAppBar(
|
||||||
|
pinned: true,
|
||||||
|
backgroundColor: AppTheme.primaryColor,
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Notificaciones',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
||||||
|
),
|
||||||
|
if (service.unreadCount > 0) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'${service.unreadCount} sin leer',
|
||||||
|
style: const TextStyle(fontSize: 11, color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
if (service.unreadCount > 0)
|
||||||
|
TextButton.icon(
|
||||||
|
icon: const Icon(Icons.done_all, color: Colors.white70, size: 18),
|
||||||
|
label: const Text(
|
||||||
|
'Marcar todo',
|
||||||
|
style: TextStyle(color: Colors.white70, fontSize: 12),
|
||||||
|
),
|
||||||
|
onPressed: service.marcarTodasLeidas,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEmptyState() {
|
||||||
|
return SliverFillRemaining(
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 80,
|
||||||
|
height: 80,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Color(0xFFEFF6FF),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: const Icon(
|
||||||
|
Icons.notifications_none_rounded,
|
||||||
|
size: 40,
|
||||||
|
color: Color(0xFF93C5FD),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
const Text(
|
||||||
|
'Sin notificaciones',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppTheme.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
const Text(
|
||||||
|
'Aquí aparecerán alertas de pedidos,\nstock, rutas y más.',
|
||||||
|
style: TextStyle(fontSize: 13, color: AppTheme.textSecondary),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildList(
|
||||||
|
BuildContext context,
|
||||||
|
NotificationService service,
|
||||||
|
List<Notificacion> notifs,
|
||||||
|
) {
|
||||||
|
final hoy = <Notificacion>[];
|
||||||
|
final antes = <Notificacion>[];
|
||||||
|
final now = DateTime.now();
|
||||||
|
|
||||||
|
for (final n in notifs) {
|
||||||
|
if (n.fecha.day == now.day && n.fecha.month == now.month && n.fecha.year == now.year) {
|
||||||
|
hoy.add(n);
|
||||||
|
} else {
|
||||||
|
antes.add(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final sections = <Widget>[];
|
||||||
|
|
||||||
|
if (hoy.isNotEmpty) {
|
||||||
|
sections.add(_buildSectionHeader('Hoy'));
|
||||||
|
sections.addAll(hoy.map((n) => _buildNotifCard(context, service, n)));
|
||||||
|
}
|
||||||
|
if (antes.isNotEmpty) {
|
||||||
|
sections.add(_buildSectionHeader('Anteriores'));
|
||||||
|
sections.addAll(antes.map((n) => _buildNotifCard(context, service, n)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return SliverList(
|
||||||
|
delegate: SliverChildListDelegate([
|
||||||
|
...sections,
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSectionHeader(String label) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 6),
|
||||||
|
child: Text(
|
||||||
|
label,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: AppTheme.textSecondary,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildNotifCard(
|
||||||
|
BuildContext context,
|
||||||
|
NotificationService service,
|
||||||
|
Notificacion notif,
|
||||||
|
) {
|
||||||
|
final color = notif.tipo.color;
|
||||||
|
final timeFmt = DateFormat('HH:mm', 'es');
|
||||||
|
final dateFmt = DateFormat('d MMM', 'es');
|
||||||
|
final isToday = notif.fecha.day == DateTime.now().day;
|
||||||
|
final timeLabel = isToday ? timeFmt.format(notif.fecha) : dateFmt.format(notif.fecha);
|
||||||
|
|
||||||
|
return Dismissible(
|
||||||
|
key: Key(notif.id),
|
||||||
|
direction: DismissDirection.endToStart,
|
||||||
|
background: Container(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
padding: const EdgeInsets.only(right: 24),
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.dangerColor,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.delete_outline, color: Colors.white, size: 24),
|
||||||
|
),
|
||||||
|
onDismissed: (_) => service.eliminar(notif.id),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if (!notif.leida) service.marcarLeida(notif.id);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: notif.leida ? Colors.white : const Color(0xFFEFF6FF),
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
border: notif.leida
|
||||||
|
? Border.all(color: Colors.transparent)
|
||||||
|
: Border(left: BorderSide(color: color, width: 3)),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.04),
|
||||||
|
blurRadius: 6,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color.withOpacity(0.12),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Icon(notif.tipo.icono, color: color, size: 20),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
notif.titulo,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: notif.leida ? FontWeight.w500 : FontWeight.bold,
|
||||||
|
color: AppTheme.textPrimary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
timeLabel,
|
||||||
|
style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
notif.cuerpo,
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
notif.tipo.label,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
color: color,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!notif.leida) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Container(
|
||||||
|
width: 7,
|
||||||
|
height: 7,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
'Sin leer',
|
||||||
|
style: TextStyle(fontSize: 10, color: color, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,315 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../models/pedido.dart';
|
||||||
|
|
||||||
|
class PedidoDetailScreen extends StatelessWidget {
|
||||||
|
final Pedido pedido;
|
||||||
|
|
||||||
|
const PedidoDetailScreen({Key? key, required this.pedido}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.read<AppProvider>();
|
||||||
|
final fmt = NumberFormat.currency(locale: 'es_BO', symbol: 'Bs.', decimalDigits: 2);
|
||||||
|
final estadoColor = AppTheme.estadoColor(pedido.estado.label);
|
||||||
|
final dateStr = DateFormat('d \'de\' MMMM yyyy, HH:mm', 'es').format(pedido.fecha);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(pedido.id, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
actions: [
|
||||||
|
PopupMenuButton<EstadoPedido>(
|
||||||
|
icon: const Icon(Icons.more_vert),
|
||||||
|
itemBuilder: (_) => EstadoPedido.values.map((e) {
|
||||||
|
return PopupMenuItem(
|
||||||
|
value: e,
|
||||||
|
child: Text(e.label),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
onSelected: (estado) {
|
||||||
|
provider.cambiarEstadoPedido(pedido.id, estado);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Header card
|
||||||
|
_buildHeaderCard(estadoColor, dateStr),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
// Cliente
|
||||||
|
_buildClienteCard(),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
// Productos
|
||||||
|
_buildProductosCard(fmt),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
// Totals
|
||||||
|
_buildTotalesCard(fmt),
|
||||||
|
if (pedido.notas.isNotEmpty) ...[
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
_buildNotasCard(),
|
||||||
|
],
|
||||||
|
if (pedido.firmaBase64 != null) ...[
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
_buildFirmaCard(),
|
||||||
|
],
|
||||||
|
const SizedBox(height: 80),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottomNavigationBar: _buildBottomBar(context, provider, estadoColor, fmt),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildHeaderCard(Color estadoColor, String dateStr) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: estadoColor.withOpacity(0.08),
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
border: Border.all(color: estadoColor.withOpacity(0.3)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: estadoColor.withOpacity(0.15),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Icon(Icons.receipt_long, color: estadoColor, size: 28),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 14),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(pedido.id,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 3),
|
||||||
|
Text(dateStr, style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: estadoColor,
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
pedido.estado.label,
|
||||||
|
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildClienteCard() {
|
||||||
|
return _sectionCard(
|
||||||
|
title: 'Cliente',
|
||||||
|
icon: Icons.store_outlined,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(pedido.cliente.nombre,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 15, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(pedido.cliente.razonSocial,
|
||||||
|
style: const TextStyle(fontSize: 13, color: AppTheme.textSecondary)),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_infoRow(Icons.location_on_outlined, pedido.cliente.direccion),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
_infoRow(Icons.phone_outlined, pedido.cliente.telefono),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
_infoRow(Icons.badge_outlined, 'NIT: ${pedido.cliente.nit}'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildProductosCard(NumberFormat fmt) {
|
||||||
|
return _sectionCard(
|
||||||
|
title: 'Productos (${pedido.items.length})',
|
||||||
|
icon: Icons.inventory_2_outlined,
|
||||||
|
child: Column(
|
||||||
|
children: pedido.items.map((item) => Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 10),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(item.producto.emoji, style: const TextStyle(fontSize: 22)),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(item.producto.nombre,
|
||||||
|
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
|
||||||
|
Text('${fmt.format(item.precioUnitario)} × ${item.cantidad} ${item.producto.unidad}',
|
||||||
|
style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
fmt.format(item.subtotal),
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: AppTheme.textPrimary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildTotalesCard(NumberFormat fmt) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_totalRow('Subtotal', fmt.format(pedido.subtotal), Colors.white70, Colors.white),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_totalRow('Descuento', '0%', Colors.white70, Colors.white),
|
||||||
|
const Divider(color: Colors.white24, height: 20),
|
||||||
|
_totalRow('TOTAL', fmt.format(pedido.total), Colors.white, Colors.white,
|
||||||
|
isTotal: true),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _totalRow(String label, String valor, Color labelColor, Color valueColor, {bool isTotal = false}) {
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(label, style: TextStyle(color: labelColor, fontSize: isTotal ? 16 : 13, fontWeight: isTotal ? FontWeight.bold : FontWeight.normal)),
|
||||||
|
Text(valor, style: TextStyle(color: valueColor, fontSize: isTotal ? 20 : 13, fontWeight: FontWeight.bold)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildNotasCard() {
|
||||||
|
return _sectionCard(
|
||||||
|
title: 'Notas',
|
||||||
|
icon: Icons.notes_outlined,
|
||||||
|
child: Text(pedido.notas, style: const TextStyle(fontSize: 13, color: AppTheme.textPrimary)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildFirmaCard() {
|
||||||
|
return _sectionCard(
|
||||||
|
title: 'Firma del cliente',
|
||||||
|
icon: Icons.draw_outlined,
|
||||||
|
child: Container(
|
||||||
|
height: 100,
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.bgColor,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.check_circle, color: AppTheme.successColor, size: 20),
|
||||||
|
SizedBox(width: 8),
|
||||||
|
Text('Pedido firmado', style: TextStyle(color: AppTheme.successColor, fontWeight: FontWeight.w600)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBottomBar(BuildContext context, AppProvider provider, Color estadoColor, NumberFormat fmt) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 8, offset: Offset(0, -2))],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.print_outlined),
|
||||||
|
label: const Text('Imprimir'),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.share_outlined),
|
||||||
|
label: const Text('Compartir'),
|
||||||
|
onPressed: () {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (pedido.estado == EstadoPedido.confirmado) ...[
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
icon: const Icon(Icons.local_shipping_outlined, size: 18),
|
||||||
|
label: const Text('Marcar entregado', style: TextStyle(fontSize: 12)),
|
||||||
|
onPressed: () {
|
||||||
|
provider.cambiarEstadoPedido(pedido.id, EstadoPedido.entregado);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _sectionCard({required String title, required IconData icon, required Widget child}) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 6)],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 17, color: AppTheme.primaryColor),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(title, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Divider(height: 16),
|
||||||
|
child,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _infoRow(IconData icon, String text) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 14, color: AppTheme.textSecondary),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Expanded(
|
||||||
|
child: Text(text, style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,515 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../models/cliente.dart';
|
||||||
|
import '../firma/firma_screen.dart';
|
||||||
|
import '../scanner/scanner_helper.dart';
|
||||||
|
import '../clientes/cliente_selector_screen.dart';
|
||||||
|
|
||||||
|
class PedidoFormScreen extends StatefulWidget {
|
||||||
|
const PedidoFormScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PedidoFormScreen> createState() => _PedidoFormScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PedidoFormScreenState extends State<PedidoFormScreen> {
|
||||||
|
final _notasCtrl = TextEditingController();
|
||||||
|
final _searchCtrl = TextEditingController();
|
||||||
|
String _productoQuery = '';
|
||||||
|
bool _showSearch = false;
|
||||||
|
|
||||||
|
final _fmt = NumberFormat.currency(locale: 'es_BO', symbol: 'Bs.', decimalDigits: 2);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
final provider = context.read<AppProvider>();
|
||||||
|
_notasCtrl.text = provider.notasPedido;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_notasCtrl.dispose();
|
||||||
|
_searchCtrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.watch<AppProvider>();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Nuevo Pedido', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.delete_outline),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => AlertDialog(
|
||||||
|
title: const Text('Cancelar pedido'),
|
||||||
|
content: const Text('¿Descartar el pedido en curso?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: () => Navigator.pop(context), child: const Text('No')),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
provider.limpiarCarrito();
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text('Sí, descartar', style: TextStyle(color: AppTheme.dangerColor)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildClienteSection(context, provider),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_buildProductoSearch(context, provider),
|
||||||
|
if (_showSearch) _buildSearchResults(context, provider),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_buildCarrito(context, provider),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_buildNotasSection(context, provider),
|
||||||
|
const SizedBox(height: 80),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_buildBottomBar(context, provider),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildClienteSection(BuildContext context, AppProvider provider) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Cliente', style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
if (provider.clienteSeleccionado != null)
|
||||||
|
_buildClienteCard(provider.clienteSeleccionado!)
|
||||||
|
else
|
||||||
|
_buildClienteSelector(context, provider),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildClienteCard(Cliente cliente) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: AppTheme.primaryColor.withOpacity(0.3)),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 6)],
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 44,
|
||||||
|
height: 44,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.store, color: AppTheme.primaryColor, size: 24),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(cliente.nombre, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||||
|
Text(cliente.direccion, style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary), maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||||
|
Text('NIT: ${cliente.nit}', style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Icon(Icons.check_circle, color: AppTheme.successColor, size: 22),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildClienteSelector(BuildContext context, AppProvider provider) {
|
||||||
|
return Material(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
elevation: 1,
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
onTap: () => _abrirSelectorCliente(context, provider),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: const Color(0xFFCBD5E1)),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.store_outlined, color: AppTheme.textSecondary),
|
||||||
|
SizedBox(width: 12),
|
||||||
|
Text('Seleccionar cliente...', style: TextStyle(color: AppTheme.textSecondary)),
|
||||||
|
Spacer(),
|
||||||
|
Icon(Icons.arrow_drop_down, color: AppTheme.textSecondary),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _abrirSelectorCliente(BuildContext context, AppProvider provider) async {
|
||||||
|
final cliente = await Navigator.push<Cliente>(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => ClienteSelectorScreen(clientes: provider.clientes),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (cliente != null) provider.seleccionarCliente(cliente);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildProductoSearch(BuildContext context, AppProvider provider) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Agregar productos', style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
controller: _searchCtrl,
|
||||||
|
onTap: () => setState(() => _showSearch = true),
|
||||||
|
onChanged: (v) => setState(() => _productoQuery = v),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Buscar producto o SKU...',
|
||||||
|
prefixIcon: const Icon(Icons.search),
|
||||||
|
suffixIcon: _showSearch
|
||||||
|
? IconButton(
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: () {
|
||||||
|
_searchCtrl.clear();
|
||||||
|
setState(() {
|
||||||
|
_productoQuery = '';
|
||||||
|
_showSearch = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Material(
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
onTap: () async {
|
||||||
|
final resultado = await abrirScanner(context, titulo: 'Escanear producto');
|
||||||
|
if (resultado == null || !mounted) return;
|
||||||
|
final coincidencias = provider.productos.where(
|
||||||
|
(p) => p.sku.toLowerCase() == resultado.toLowerCase() ||
|
||||||
|
p.nombre.toLowerCase().contains(resultado.toLowerCase()),
|
||||||
|
).toList();
|
||||||
|
final producto = coincidencias.isEmpty ? null : coincidencias.first;
|
||||||
|
if (producto != null) {
|
||||||
|
provider.agregarAlCarrito(producto);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
|
content: Text('${producto.nombre} agregado al pedido'),
|
||||||
|
backgroundColor: AppTheme.successColor,
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
// Si no coincide exacto, poner en el campo de búsqueda
|
||||||
|
_searchCtrl.text = resultado;
|
||||||
|
setState(() {
|
||||||
|
_productoQuery = resultado;
|
||||||
|
_showSearch = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Padding(
|
||||||
|
padding: EdgeInsets.all(14),
|
||||||
|
child: Icon(Icons.qr_code_scanner, color: Colors.white, size: 22),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSearchResults(BuildContext context, AppProvider provider) {
|
||||||
|
final results = provider.productos.where((p) {
|
||||||
|
if (_productoQuery.isEmpty) return true;
|
||||||
|
return p.nombre.toLowerCase().contains(_productoQuery.toLowerCase()) ||
|
||||||
|
p.sku.toLowerCase().contains(_productoQuery.toLowerCase());
|
||||||
|
}).take(6).toList();
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.only(top: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.08), blurRadius: 8)],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: results.map((p) {
|
||||||
|
final enCarrito = provider.carrito.where((i) => i.producto.id == p.id);
|
||||||
|
final qty = enCarrito.isNotEmpty ? enCarrito.first.cantidad : 0;
|
||||||
|
return ListTile(
|
||||||
|
dense: true,
|
||||||
|
leading: Text(p.emoji, style: const TextStyle(fontSize: 24)),
|
||||||
|
title: Text(p.nombre, style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
|
||||||
|
subtitle: Text(_fmt.format(p.precio), style: const TextStyle(fontSize: 12, color: AppTheme.primaryColor)),
|
||||||
|
trailing: qty == 0
|
||||||
|
? IconButton(
|
||||||
|
icon: const Icon(Icons.add_circle, color: AppTheme.primaryColor),
|
||||||
|
onPressed: () => provider.agregarAlCarrito(p),
|
||||||
|
)
|
||||||
|
: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.remove_circle_outline, size: 20),
|
||||||
|
onPressed: () => provider.actualizarCantidad(p.id, qty - 1),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||||
|
child: Text('$qty', style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.add_circle, size: 20, color: AppTheme.primaryColor),
|
||||||
|
onPressed: () => provider.agregarAlCarrito(p),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildCarrito(BuildContext context, AppProvider provider) {
|
||||||
|
if (provider.carrito.isEmpty) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 32),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: const Color(0xFFE2E8F0), style: BorderStyle.solid),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.shopping_cart_outlined, size: 40, color: AppTheme.textSecondary),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
Text('Carrito vacío', style: TextStyle(color: AppTheme.textSecondary)),
|
||||||
|
Text('Busca y agrega productos arriba', style: TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text('Carrito (${provider.carrito.length} productos)',
|
||||||
|
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
TextButton.icon(
|
||||||
|
icon: const Icon(Icons.delete_outline, size: 16),
|
||||||
|
label: const Text('Limpiar', style: TextStyle(fontSize: 12)),
|
||||||
|
onPressed: provider.limpiarCarrito,
|
||||||
|
style: TextButton.styleFrom(primary: AppTheme.dangerColor),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 6)],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
...provider.carrito.map((item) => Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(bottom: BorderSide(color: Colors.grey.shade100)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Text(item.producto.emoji, style: const TextStyle(fontSize: 20)),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(item.producto.nombre, style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
|
||||||
|
Text('${_fmt.format(item.precioUnitario)} x ${item.cantidad}',
|
||||||
|
style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
_counterBtn(Icons.remove, () => provider.actualizarCantidad(item.producto.id, item.cantidad - 1)),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
|
child: Text('${item.cantidad}', style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||||
|
),
|
||||||
|
_counterBtn(Icons.add, () => provider.agregarAlCarrito(item.producto)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
_fmt.format(item.subtotal),
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13, color: AppTheme.primaryColor),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close, size: 16, color: AppTheme.textSecondary),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () => provider.quitarDelCarrito(item.producto.id),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)).toList(),
|
||||||
|
// Totals
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor.withOpacity(0.04),
|
||||||
|
borderRadius: const BorderRadius.vertical(bottom: Radius.circular(12)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text('${provider.cantidadCarrito} unidades', style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
const Text('Total a pagar:', style: TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
_fmt.format(provider.totalCarrito),
|
||||||
|
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: AppTheme.primaryColor),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildNotasSection(BuildContext context, AppProvider provider) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Notas del pedido', style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
TextField(
|
||||||
|
controller: _notasCtrl,
|
||||||
|
onChanged: provider.setNotasPedido,
|
||||||
|
maxLines: 3,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Instrucciones especiales, horario de entrega...',
|
||||||
|
alignLabelWithHint: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildBottomBar(BuildContext context, AppProvider provider) {
|
||||||
|
final canConfirm = provider.clienteSeleccionado != null && provider.carrito.isNotEmpty;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.08), blurRadius: 12, offset: const Offset(0, -4))],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text('Total del pedido:', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500)),
|
||||||
|
Text(
|
||||||
|
_fmt.format(provider.totalCarrito),
|
||||||
|
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: AppTheme.primaryColor),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 52,
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
icon: const Icon(Icons.draw_outlined, size: 22),
|
||||||
|
label: const Text('Confirmar y Firmar', style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
|
||||||
|
onPressed: canConfirm
|
||||||
|
? () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const FirmaScreen()),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _counterBtn(IconData icon, VoidCallback onTap) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(3),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: Icon(icon, size: 16, color: AppTheme.primaryColor),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,279 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../models/pedido.dart';
|
||||||
|
import 'pedido_form_screen.dart';
|
||||||
|
import 'pedido_detail_screen.dart';
|
||||||
|
|
||||||
|
class PedidosScreen extends StatefulWidget {
|
||||||
|
const PedidosScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PedidosScreen> createState() => _PedidosScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PedidosScreenState extends State<PedidosScreen> with SingleTickerProviderStateMixin {
|
||||||
|
late TabController _tab;
|
||||||
|
final _fmt = NumberFormat.currency(locale: 'es_BO', symbol: 'Bs.', decimalDigits: 2);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_tab = TabController(length: 4, vsync: this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_tab.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.watch<AppProvider>();
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Pedidos', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
|
actions: [
|
||||||
|
IconButton(icon: const Icon(Icons.search), onPressed: () {}),
|
||||||
|
IconButton(icon: const Icon(Icons.filter_list), onPressed: () {}),
|
||||||
|
],
|
||||||
|
bottom: TabBar(
|
||||||
|
controller: _tab,
|
||||||
|
indicatorColor: Colors.white,
|
||||||
|
indicatorWeight: 3,
|
||||||
|
isScrollable: true,
|
||||||
|
tabs: _buildTabs(provider),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: TabBarView(
|
||||||
|
controller: _tab,
|
||||||
|
children: [
|
||||||
|
_buildList(context, provider.pedidos, provider),
|
||||||
|
_buildList(
|
||||||
|
context,
|
||||||
|
provider.pedidos.where((p) => p.estado == EstadoPedido.pendiente).toList(),
|
||||||
|
provider),
|
||||||
|
_buildList(
|
||||||
|
context,
|
||||||
|
provider.pedidos.where((p) => p.estado == EstadoPedido.confirmado).toList(),
|
||||||
|
provider),
|
||||||
|
_buildList(
|
||||||
|
context,
|
||||||
|
provider.pedidos.where((p) => p.estado == EstadoPedido.entregado).toList(),
|
||||||
|
provider),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const PedidoFormScreen()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.add),
|
||||||
|
label: const Text('Nuevo pedido'),
|
||||||
|
backgroundColor: AppTheme.primaryColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _buildTabs(AppProvider provider) {
|
||||||
|
final todos = provider.pedidos.length;
|
||||||
|
final pend = provider.pedidos.where((p) => p.estado == EstadoPedido.pendiente).length;
|
||||||
|
final conf = provider.pedidos.where((p) => p.estado == EstadoPedido.confirmado).length;
|
||||||
|
final entr = provider.pedidos.where((p) => p.estado == EstadoPedido.entregado).length;
|
||||||
|
|
||||||
|
return [
|
||||||
|
Tab(text: 'Todos ($todos)'),
|
||||||
|
Tab(text: 'Pendiente ($pend)'),
|
||||||
|
Tab(text: 'Confirmado ($conf)'),
|
||||||
|
Tab(text: 'Entregado ($entr)'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildList(BuildContext context, List<Pedido> pedidos, AppProvider provider) {
|
||||||
|
if (pedidos.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.receipt_long_outlined, size: 64, color: Colors.grey.shade300),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
const Text('No hay pedidos', style: TextStyle(color: AppTheme.textSecondary, fontSize: 15)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ListView.builder(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 80),
|
||||||
|
itemCount: pedidos.length,
|
||||||
|
itemBuilder: (context, i) => _buildPedidoCard(context, pedidos[i], provider),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildPedidoCard(BuildContext context, Pedido pedido, AppProvider provider) {
|
||||||
|
final estadoColor = AppTheme.estadoColor(pedido.estado.label);
|
||||||
|
final timeStr = DateFormat('d MMM, HH:mm', 'es').format(pedido.fecha);
|
||||||
|
|
||||||
|
return Dismissible(
|
||||||
|
key: Key(pedido.id),
|
||||||
|
direction: DismissDirection.endToStart,
|
||||||
|
background: Container(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
padding: const EdgeInsets.only(right: 20),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.dangerColor,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.delete_outline, color: Colors.white, size: 28),
|
||||||
|
SizedBox(height: 4),
|
||||||
|
Text('Eliminar', style: TextStyle(color: Colors.white, fontSize: 11)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
confirmDismiss: (dir) async {
|
||||||
|
return await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => AlertDialog(
|
||||||
|
title: const Text('Eliminar pedido'),
|
||||||
|
content: Text('¿Eliminar el pedido ${pedido.id}?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Cancelar')),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(ctx, true),
|
||||||
|
child: const Text('Eliminar', style: TextStyle(color: AppTheme.dangerColor)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
) ?? false;
|
||||||
|
},
|
||||||
|
onDismissed: (_) => provider.eliminarPedido(pedido.id),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => PedidoDetailScreen(pedido: pedido)),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(bottom: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
border: Border.all(color: estadoColor.withOpacity(0.2)),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 6, offset: const Offset(0, 2))],
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: estadoColor.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Icon(Icons.receipt_outlined, color: estadoColor, size: 20),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
pedido.id,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: AppTheme.textPrimary),
|
||||||
|
),
|
||||||
|
Text(timeStr, style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: estadoColor.withOpacity(0.12),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
pedido.estado.label,
|
||||||
|
style: TextStyle(fontSize: 11, color: estadoColor, fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Divider(height: 16),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.store_outlined, size: 14, color: AppTheme.textSecondary),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
pedido.cliente.nombre,
|
||||||
|
style: const TextStyle(fontSize: 13, color: AppTheme.textPrimary, fontWeight: FontWeight.w500),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.inventory_2_outlined, size: 14, color: AppTheme.textSecondary),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
'${pedido.totalItems} productos · ${pedido.items.length} líneas',
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Text(
|
||||||
|
_fmt.format(pedido.total),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (pedido.notas.isNotEmpty) ...[
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.bgColor,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.notes, size: 13, color: AppTheme.textSecondary),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
pedido.notas,
|
||||||
|
style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,337 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../models/pedido.dart';
|
||||||
|
|
||||||
|
class PerfilScreen extends StatelessWidget {
|
||||||
|
const PerfilScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.watch<AppProvider>();
|
||||||
|
final vendedor = provider.vendedor;
|
||||||
|
final fmt = NumberFormat.currency(locale: 'es_BO', symbol: 'Bs.', decimalDigits: 2);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
body: CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
_buildSliverHeader(context, vendedor, provider),
|
||||||
|
SliverPadding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
sliver: SliverList(
|
||||||
|
delegate: SliverChildListDelegate([
|
||||||
|
_buildStatsRow(provider, fmt),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildRutaProgress(provider),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildPedidosResumen(context, provider, fmt),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildInfoCard(vendedor),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildConfigSection(context),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildLogoutBtn(context, provider),
|
||||||
|
const SizedBox(height: 40),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSliverHeader(BuildContext context, vendedor, AppProvider provider) {
|
||||||
|
return SliverAppBar(
|
||||||
|
expandedHeight: 200,
|
||||||
|
pinned: true,
|
||||||
|
backgroundColor: AppTheme.primaryColor,
|
||||||
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
|
background: Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [Color(0xFF1E3A8A), Color(0xFF2563EB)],
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 40,
|
||||||
|
backgroundColor: Colors.white.withOpacity(0.2),
|
||||||
|
child: Text(
|
||||||
|
vendedor.avatarInitials,
|
||||||
|
style: const TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(vendedor.nombre,
|
||||||
|
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.white)),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.location_on, color: Colors.white70, size: 14),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(vendedor.zona,
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w500)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text(vendedor.nombre, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
||||||
|
titlePadding: const EdgeInsets.only(left: 16, bottom: 12),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildStatsRow(AppProvider provider, NumberFormat fmt) {
|
||||||
|
final stats = [
|
||||||
|
{'label': 'Pedidos hoy', 'value': '${provider.pedidosHoy}', 'color': AppTheme.primaryColor},
|
||||||
|
{'label': 'Ventas hoy', 'value': fmt.format(provider.ventasTotalesHoy), 'color': AppTheme.successColor},
|
||||||
|
{
|
||||||
|
'label': 'Clientes',
|
||||||
|
'value': '${provider.ruta.visitadas}/${provider.ruta.paradas.length}',
|
||||||
|
'color': AppTheme.accentColor
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
children: stats.map((s) {
|
||||||
|
final color = s['color'] as Color;
|
||||||
|
return Expanded(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
boxShadow: [BoxShadow(color: color.withOpacity(0.1), blurRadius: 8)],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(s['value'] as String,
|
||||||
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: color)),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(s['label'] as String,
|
||||||
|
style: const TextStyle(fontSize: 10, color: AppTheme.textSecondary), textAlign: TextAlign.center),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildRutaProgress(AppProvider provider) {
|
||||||
|
final ruta = provider.ruta;
|
||||||
|
final progress = ruta.paradas.isEmpty ? 0.0 : ruta.visitadas / ruta.paradas.length;
|
||||||
|
|
||||||
|
return _card(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Text('Progreso de ruta', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||||
|
Text('${(progress * 100).toInt()}% completado',
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
child: LinearProgressIndicator(
|
||||||
|
value: progress,
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
valueColor: AlwaysStoppedAnimation<Color>(
|
||||||
|
progress == 1.0 ? AppTheme.successColor : AppTheme.primaryColor,
|
||||||
|
),
|
||||||
|
minHeight: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
_progressChip(Icons.check_circle, '${ruta.visitadas} visitadas', AppTheme.successColor),
|
||||||
|
_progressChip(Icons.pending, '${ruta.pendientes} pendientes', AppTheme.warningColor),
|
||||||
|
_progressChip(Icons.location_on, '${ruta.paradas.length} total', AppTheme.primaryColor),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _progressChip(IconData icon, String label, Color color) {
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 14, color: color),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(label, style: TextStyle(fontSize: 11, color: color, fontWeight: FontWeight.w500)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildPedidosResumen(BuildContext context, AppProvider provider, NumberFormat fmt) {
|
||||||
|
final estados = {
|
||||||
|
EstadoPedido.confirmado: provider.pedidos.where((p) => p.estado == EstadoPedido.confirmado).length,
|
||||||
|
EstadoPedido.entregado: provider.pedidos.where((p) => p.estado == EstadoPedido.entregado).length,
|
||||||
|
EstadoPedido.pendiente: provider.pedidos.where((p) => p.estado == EstadoPedido.pendiente).length,
|
||||||
|
EstadoPedido.cancelado: provider.pedidos.where((p) => p.estado == EstadoPedido.cancelado).length,
|
||||||
|
};
|
||||||
|
|
||||||
|
return _card(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Resumen de pedidos', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
...estados.entries.map((e) {
|
||||||
|
final color = AppTheme.estadoColor(e.key.label);
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(width: 10, height: 10, decoration: BoxDecoration(color: color, shape: BoxShape.circle)),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text(e.key.label, style: const TextStyle(fontSize: 13)),
|
||||||
|
const Spacer(),
|
||||||
|
Text('${e.value}', style: TextStyle(fontWeight: FontWeight.bold, color: color)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildInfoCard(vendedor) {
|
||||||
|
return _card(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Información de contacto', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
_infoTile(Icons.email_outlined, 'Correo', vendedor.email),
|
||||||
|
_infoTile(Icons.phone_outlined, 'Teléfono', vendedor.telefono),
|
||||||
|
_infoTile(Icons.map_outlined, 'Zona', vendedor.zona),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _infoTile(IconData icon, String label, String value) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 10),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 18, color: AppTheme.primaryColor),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(label, style: const TextStyle(fontSize: 10, color: AppTheme.textSecondary)),
|
||||||
|
Text(value, style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildConfigSection(BuildContext context) {
|
||||||
|
final opciones = [
|
||||||
|
{'icon': Icons.notifications_outlined, 'label': 'Notificaciones', 'trailing': true},
|
||||||
|
{'icon': Icons.language, 'label': 'Idioma', 'value': 'Español'},
|
||||||
|
{'icon': Icons.help_outline, 'label': 'Ayuda y soporte', 'arrow': true},
|
||||||
|
{'icon': Icons.info_outline, 'label': 'Acerca de la app', 'value': 'v1.0.0'},
|
||||||
|
];
|
||||||
|
|
||||||
|
return _card(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Configuración', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
...opciones.map((o) => ListTile(
|
||||||
|
dense: true,
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
leading: Icon(o['icon'] as IconData, color: AppTheme.primaryColor, size: 22),
|
||||||
|
title: Text(o['label'] as String, style: const TextStyle(fontSize: 13)),
|
||||||
|
trailing: o['trailing'] == true
|
||||||
|
? Switch(value: true, onChanged: (_) {}, activeColor: AppTheme.primaryColor)
|
||||||
|
: o['arrow'] == true
|
||||||
|
? const Icon(Icons.chevron_right, color: AppTheme.textSecondary)
|
||||||
|
: Text(o['value'] as String? ?? '', style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
onTap: () {},
|
||||||
|
)).toList(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildLogoutBtn(BuildContext context, AppProvider provider) {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 50,
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.logout, color: AppTheme.dangerColor),
|
||||||
|
label: const Text('Cerrar sesión', style: TextStyle(color: AppTheme.dangerColor, fontWeight: FontWeight.w600)),
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
side: const BorderSide(color: AppTheme.dangerColor),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => AlertDialog(
|
||||||
|
title: const Text('Cerrar sesión'),
|
||||||
|
content: const Text('¿Seguro que deseas salir?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: () => Navigator.pop(context), child: const Text('Cancelar')),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
provider.logout();
|
||||||
|
},
|
||||||
|
child: const Text('Salir', style: TextStyle(color: AppTheme.dangerColor)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _card({required Widget child}) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 6)],
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,840 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import '../../providers/app_provider.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
import '../../models/cliente.dart';
|
||||||
|
import '../../models/parada_ruta.dart';
|
||||||
|
import '../../widgets/route_map_painter.dart';
|
||||||
|
import '../clientes/cliente_form_screen.dart';
|
||||||
|
import '../pedidos/pedido_form_screen.dart';
|
||||||
|
|
||||||
|
class RutasScreen extends StatefulWidget {
|
||||||
|
const RutasScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RutasScreen> createState() => _RutasScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RutasScreenState extends State<RutasScreen> with SingleTickerProviderStateMixin {
|
||||||
|
late TabController _tabController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_tabController = TabController(length: 2, vsync: this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_tabController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final provider = context.watch<AppProvider>();
|
||||||
|
final ruta = provider.ruta;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: AppTheme.bgColor,
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Text('Ruta del Día', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 17)),
|
||||||
|
Text(ruta.zona, style: const TextStyle(fontSize: 12, fontWeight: FontWeight.normal, color: Colors.white70)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 8),
|
||||||
|
child: Chip(
|
||||||
|
label: Text(
|
||||||
|
'${ruta.visitadas}/${ruta.paradas.length}',
|
||||||
|
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12),
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white.withOpacity(0.2),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
bottom: TabBar(
|
||||||
|
controller: _tabController,
|
||||||
|
indicatorColor: Colors.white,
|
||||||
|
indicatorWeight: 3,
|
||||||
|
tabs: const [
|
||||||
|
Tab(icon: Icon(Icons.map_outlined, size: 18), text: 'Mapa'),
|
||||||
|
Tab(icon: Icon(Icons.list_alt, size: 18), text: 'Paradas'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: TabBarView(
|
||||||
|
controller: _tabController,
|
||||||
|
children: [
|
||||||
|
_buildMapView(context, provider),
|
||||||
|
_buildListView(context, provider),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
floatingActionButton: FloatingActionButton.extended(
|
||||||
|
onPressed: () => _showAgregarParadaSheet(context, provider),
|
||||||
|
icon: const Icon(Icons.add_location_alt_outlined),
|
||||||
|
label: const Text('Agregar parada'),
|
||||||
|
backgroundColor: AppTheme.accentColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMapView(BuildContext context, AppProvider provider) {
|
||||||
|
final ruta = provider.ruta;
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(color: Colors.black.withOpacity(0.1), blurRadius: 12, offset: const Offset(0, 4)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
CustomPaint(
|
||||||
|
painter: RouteMapPainter(ruta.paradas),
|
||||||
|
child: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
// Map legend
|
||||||
|
Positioned(
|
||||||
|
top: 12,
|
||||||
|
right: 12,
|
||||||
|
child: _buildLegend(),
|
||||||
|
),
|
||||||
|
// Controls
|
||||||
|
Positioned(
|
||||||
|
bottom: 12,
|
||||||
|
right: 12,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_mapButton(Icons.add, () {}),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_mapButton(Icons.remove, () {}),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
_mapButton(Icons.my_location, () {}),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: ListView.builder(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||||
|
itemCount: ruta.paradas.length,
|
||||||
|
itemBuilder: (context, i) => _buildParadaMini(context, ruta.paradas[i], provider),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildLegend() {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withOpacity(0.92),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.1), blurRadius: 4)],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_legendItem(AppTheme.successColor, 'Visitado'),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
_legendItem(AppTheme.accentColor, 'Actual'),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
_legendItem(AppTheme.primaryColor.withOpacity(0.5), 'Pendiente'),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
_legendItem(Colors.blue, 'Mi ubicación'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _legendItem(Color color, String label) {
|
||||||
|
return Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(width: 10, height: 10, decoration: BoxDecoration(color: color, shape: BoxShape.circle)),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(label, style: const TextStyle(fontSize: 10, color: AppTheme.textPrimary)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _mapButton(IconData icon, VoidCallback onTap) {
|
||||||
|
return Material(
|
||||||
|
color: Colors.white,
|
||||||
|
elevation: 2,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: InkWell(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
onTap: onTap,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Icon(icon, size: 20, color: AppTheme.primaryColor),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildParadaMini(BuildContext context, ParadaRuta parada, AppProvider provider) {
|
||||||
|
final isVisited = parada.estado == EstadoParada.visitado;
|
||||||
|
final color = isVisited ? AppTheme.successColor : AppTheme.primaryColor;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(color: color.withOpacity(0.3)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 14,
|
||||||
|
backgroundColor: color.withOpacity(0.15),
|
||||||
|
child: Text('${parada.orden}', style: TextStyle(color: color, fontWeight: FontWeight.bold, fontSize: 12)),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
parada.cliente.nombre,
|
||||||
|
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (isVisited)
|
||||||
|
const Icon(Icons.check_circle, color: AppTheme.successColor, size: 18)
|
||||||
|
else
|
||||||
|
TextButton(
|
||||||
|
style: TextButton.styleFrom(padding: const EdgeInsets.symmetric(horizontal: 8), minimumSize: Size.zero),
|
||||||
|
onPressed: () => _tabController.animateTo(1),
|
||||||
|
child: const Text('Ir', style: TextStyle(fontSize: 12)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildListView(BuildContext context, AppProvider provider) {
|
||||||
|
final ruta = provider.ruta;
|
||||||
|
return ListView.builder(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 90),
|
||||||
|
itemCount: ruta.paradas.length,
|
||||||
|
itemBuilder: (context, i) {
|
||||||
|
final parada = ruta.paradas[i];
|
||||||
|
final puedeEliminar = parada.estado == EstadoParada.pendiente;
|
||||||
|
return Dismissible(
|
||||||
|
key: Key(parada.id),
|
||||||
|
direction: puedeEliminar ? DismissDirection.endToStart : DismissDirection.none,
|
||||||
|
background: Container(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
padding: const EdgeInsets.only(right: 20),
|
||||||
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.dangerColor,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.delete_outline, color: Colors.white, size: 26),
|
||||||
|
SizedBox(height: 4),
|
||||||
|
Text('Quitar', style: TextStyle(color: Colors.white, fontSize: 11)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
confirmDismiss: (_) async => await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => AlertDialog(
|
||||||
|
title: const Text('Quitar parada'),
|
||||||
|
content: Text('¿Quitar a ${parada.cliente.nombre} de la ruta de hoy?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Cancelar')),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(ctx, true),
|
||||||
|
child: const Text('Quitar', style: TextStyle(color: AppTheme.dangerColor)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
) ?? false,
|
||||||
|
onDismissed: (_) {
|
||||||
|
provider.eliminarParada(parada.id);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('${parada.cliente.nombre} quitado de la ruta'),
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: _buildParadaCard(context, parada, provider),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildParadaCard(BuildContext context, ParadaRuta parada, AppProvider provider) {
|
||||||
|
final isVisited = parada.estado == EstadoParada.visitado;
|
||||||
|
final isSaltado = parada.estado == EstadoParada.saltado;
|
||||||
|
final color = isVisited
|
||||||
|
? AppTheme.successColor
|
||||||
|
: isSaltado
|
||||||
|
? AppTheme.dangerColor
|
||||||
|
: AppTheme.primaryColor;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.only(bottom: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
border: Border.all(color: color.withOpacity(0.25)),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.04), blurRadius: 6, offset: const Offset(0, 2))],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color.withOpacity(0.15),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: isVisited
|
||||||
|
? const Icon(Icons.check, color: AppTheme.successColor, size: 20)
|
||||||
|
: Center(
|
||||||
|
child: Text(
|
||||||
|
'${parada.orden}',
|
||||||
|
style: TextStyle(color: color, fontWeight: FontWeight.bold, fontSize: 14),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
parada.cliente.nombre,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: AppTheme.textPrimary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color.withOpacity(0.12),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
isVisited ? 'Visitado' : isSaltado ? 'Saltado' : 'Pendiente',
|
||||||
|
style: TextStyle(fontSize: 10, color: color, fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 3),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.location_on_outlined, size: 13, color: AppTheme.textSecondary),
|
||||||
|
const SizedBox(width: 2),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
parada.cliente.direccion,
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 3),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.access_time, size: 13, color: AppTheme.textSecondary),
|
||||||
|
const SizedBox(width: 2),
|
||||||
|
Text(
|
||||||
|
isVisited
|
||||||
|
? 'Visitado a las ${parada.horaVisita}'
|
||||||
|
: 'Estimado: ${parada.horaEstimada}',
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 3),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.category_outlined, size: 13, color: AppTheme.textSecondary),
|
||||||
|
const SizedBox(width: 2),
|
||||||
|
Text(
|
||||||
|
parada.cliente.categoria,
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!isVisited && !isSaltado)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(14, 0, 14, 14),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.phone, size: 16),
|
||||||
|
label: const Text('Llamar', style: TextStyle(fontSize: 13)),
|
||||||
|
onPressed: () {},
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.directions, size: 16),
|
||||||
|
label: const Text('Navegar', style: TextStyle(fontSize: 13)),
|
||||||
|
onPressed: () {},
|
||||||
|
style: OutlinedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
icon: const Icon(Icons.add_shopping_cart, size: 16),
|
||||||
|
label: const Text('Tomar pedido', style: TextStyle(fontSize: 12)),
|
||||||
|
onPressed: () {
|
||||||
|
provider.seleccionarCliente(parada.cliente);
|
||||||
|
provider.marcarParadaVisitada(parada.id);
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const PedidoFormScreen()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showAgregarParadaSheet(BuildContext context, AppProvider provider) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
shape: const RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
|
||||||
|
),
|
||||||
|
builder: (ctx) => _AgregarParadaSheet(provider: provider),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────
|
||||||
|
// Bottom sheet: seleccionar cliente registrado O crear nuevo
|
||||||
|
// ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
class _AgregarParadaSheet extends StatefulWidget {
|
||||||
|
final AppProvider provider;
|
||||||
|
const _AgregarParadaSheet({Key? key, required this.provider}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_AgregarParadaSheet> createState() => _AgregarParadaSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AgregarParadaSheetState extends State<_AgregarParadaSheet>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late TabController _tab;
|
||||||
|
Cliente? _clienteElegido;
|
||||||
|
final _horaCtrl = TextEditingController();
|
||||||
|
final _searchCtrl = TextEditingController();
|
||||||
|
String _query = '';
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_tab = TabController(length: 2, vsync: this);
|
||||||
|
final now = DateTime.now();
|
||||||
|
final h = now.hour.toString().padLeft(2, '0');
|
||||||
|
final m = ((now.minute ~/ 15 + 1) * 15 % 60).toString().padLeft(2, '0');
|
||||||
|
_horaCtrl.text = '$h:$m';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_tab.dispose();
|
||||||
|
_horaCtrl.dispose();
|
||||||
|
_searchCtrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final todosDisponibles = widget.provider.clientesSinParada
|
||||||
|
.where((c) => _query.isEmpty || c.nombre.toLowerCase().contains(_query.toLowerCase()) ||
|
||||||
|
c.nit.toLowerCase().contains(_query.toLowerCase()))
|
||||||
|
.toList();
|
||||||
|
final hayMas = todosDisponibles.length > 50;
|
||||||
|
final disponibles = hayMas ? todosDisponibles.take(50).toList() : todosDisponibles;
|
||||||
|
|
||||||
|
return DraggableScrollableSheet(
|
||||||
|
expand: false,
|
||||||
|
initialChildSize: 0.75,
|
||||||
|
minChildSize: 0.5,
|
||||||
|
maxChildSize: 0.95,
|
||||||
|
builder: (_, scrollCtrl) => Column(
|
||||||
|
children: [
|
||||||
|
// Handle + header
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(20, 12, 20, 0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Container(
|
||||||
|
width: 40, height: 4,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey.shade300,
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.accentColor.withOpacity(0.12),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.add_location_alt, color: AppTheme.accentColor, size: 22),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: const [
|
||||||
|
Text('Agregar parada',
|
||||||
|
style: TextStyle(fontSize: 17, fontWeight: FontWeight.bold, color: AppTheme.textPrimary)),
|
||||||
|
Text('Selecciona un cliente o registra uno nuevo',
|
||||||
|
style: TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
// Tabs
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.bgColor,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: TabBar(
|
||||||
|
controller: _tab,
|
||||||
|
indicator: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
labelColor: Colors.white,
|
||||||
|
unselectedLabelColor: AppTheme.textSecondary,
|
||||||
|
labelStyle: const TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
|
||||||
|
tabs: const [
|
||||||
|
Tab(text: 'Cliente registrado'),
|
||||||
|
Tab(text: 'Cliente nuevo'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
controller: _tab,
|
||||||
|
children: [
|
||||||
|
// ── TAB 1: cliente registrado ──
|
||||||
|
_buildRegistradosTab(disponibles, scrollCtrl, hayMas),
|
||||||
|
// ── TAB 2: cliente nuevo ──
|
||||||
|
_buildNuevoTab(scrollCtrl),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildRegistradosTab(List<Cliente> disponibles, ScrollController scrollCtrl, bool hayMas) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 6),
|
||||||
|
child: TextField(
|
||||||
|
controller: _searchCtrl,
|
||||||
|
onChanged: (v) => setState(() => _query = v),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Buscar cliente...',
|
||||||
|
prefixIcon: const Icon(Icons.search, size: 20),
|
||||||
|
suffixIcon: _query.isNotEmpty
|
||||||
|
? IconButton(
|
||||||
|
icon: const Icon(Icons.clear, size: 18),
|
||||||
|
onPressed: () {
|
||||||
|
_searchCtrl.clear();
|
||||||
|
setState(() => _query = '');
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
isDense: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (disponibles.isEmpty)
|
||||||
|
Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.store_outlined, size: 48, color: Colors.grey.shade300),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Text('No hay clientes disponibles',
|
||||||
|
style: TextStyle(color: AppTheme.textSecondary)),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
const Text('Todos ya están en la ruta o\ncambia el filtro de búsqueda',
|
||||||
|
style: TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
textAlign: TextAlign.center),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
controller: scrollCtrl,
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
||||||
|
itemCount: disponibles.length + (hayMas ? 1 : 0),
|
||||||
|
itemBuilder: (_, i) {
|
||||||
|
if (i == disponibles.length) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: Text(
|
||||||
|
'Hay más clientes — refina la búsqueda para verlos',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 12, color: Colors.grey.shade500),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final c = disponibles[i];
|
||||||
|
final selected = _clienteElegido?.id == c.id;
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: () => setState(() => _clienteElegido = c),
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: const Duration(milliseconds: 150),
|
||||||
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: selected ? AppTheme.primaryColor.withOpacity(0.07) : Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: selected ? AppTheme.primaryColor : const Color(0xFFE2E8F0),
|
||||||
|
width: selected ? 1.5 : 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 20,
|
||||||
|
backgroundColor: selected
|
||||||
|
? AppTheme.primaryColor.withOpacity(0.15)
|
||||||
|
: const Color(0xFFF1F5F9),
|
||||||
|
child: Icon(Icons.store, size: 20,
|
||||||
|
color: selected ? AppTheme.primaryColor : AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(c.nombre,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: selected ? AppTheme.primaryColor : AppTheme.textPrimary,
|
||||||
|
)),
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(c.categoria,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
color: selected ? AppTheme.primaryColor.withOpacity(0.7) : AppTheme.textSecondary,
|
||||||
|
)),
|
||||||
|
Text(c.direccion,
|
||||||
|
style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (selected)
|
||||||
|
const Icon(Icons.check_circle, color: AppTheme.primaryColor, size: 22),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Footer
|
||||||
|
if (_clienteElegido != null)
|
||||||
|
_buildFooter(context),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildNuevoTab(ScrollController scrollCtrl) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
controller: scrollCtrl,
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
// Info banner
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(14),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.primaryColor.withOpacity(0.06),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: AppTheme.primaryColor.withOpacity(0.2)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.info_outline, color: AppTheme.primaryColor, size: 18),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'El nuevo cliente quedará registrado en el sistema y se agregará como parada a tu ruta de hoy.',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: AppTheme.primaryColor.withOpacity(0.85),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 52,
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
icon: const Icon(Icons.person_add_alt_1_outlined, size: 22),
|
||||||
|
label: const Text('Abrir formulario de registro',
|
||||||
|
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600)),
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.pop(context); // cierra el sheet
|
||||||
|
final nuevoCliente = await Navigator.push<Cliente>(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (_) => const ClienteFormScreen(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// Si se creó con agregarARuta = true, el provider ya lo hizo.
|
||||||
|
// Si no, el cliente quedó registrado pero no en ruta.
|
||||||
|
if (nuevoCliente != null) {
|
||||||
|
// nada extra que hacer — el provider ya notificó
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildFooter(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 10, 16, 20),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border: Border(top: BorderSide(color: Color(0xFFE2E8F0))),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'Cliente seleccionado: ${_clienteElegido!.nombre}',
|
||||||
|
style: const TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
controller: _horaCtrl,
|
||||||
|
keyboardType: TextInputType.datetime,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Hora estimada',
|
||||||
|
prefixIcon: Icon(Icons.access_time, size: 18),
|
||||||
|
isDense: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: ElevatedButton.icon(
|
||||||
|
icon: const Icon(Icons.add_location_alt_outlined, size: 18),
|
||||||
|
label: const Text('Agregar a ruta'),
|
||||||
|
onPressed: () {
|
||||||
|
final hora = _horaCtrl.text.trim().isEmpty ? '—' : _horaCtrl.text.trim();
|
||||||
|
widget.provider.agregarParadaARuta(_clienteElegido!, hora);
|
||||||
|
Navigator.pop(context);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('✓ ${_clienteElegido!.nombre} agregado a la ruta'),
|
||||||
|
backgroundColor: AppTheme.successColor,
|
||||||
|
behavior: SnackBarBehavior.floating,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import 'dart:io' show Platform;
|
||||||
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'scanner_screen.dart';
|
||||||
|
|
||||||
|
/// Abre el scanner de cámara en móvil/web, o un diálogo de entrada manual en Linux/Windows.
|
||||||
|
/// Retorna el valor escaneado/ingresado, o null si el usuario canceló.
|
||||||
|
Future<String?> abrirScanner(BuildContext context, {String titulo = 'Escanear código'}) {
|
||||||
|
if (!kIsWeb && (Platform.isLinux || Platform.isWindows)) {
|
||||||
|
return _mostrarInputManual(context, titulo: titulo);
|
||||||
|
}
|
||||||
|
return Navigator.push<String>(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => ScannerScreen(titulo: titulo)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String?> _mostrarInputManual(BuildContext context, {required String titulo}) {
|
||||||
|
final ctrl = TextEditingController();
|
||||||
|
return showDialog<String>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => AlertDialog(
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.qr_code, size: 22),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(titulo, style: const TextStyle(fontSize: 16)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
'Escaneo de cámara no disponible en escritorio.\nIngresa el código manualmente:',
|
||||||
|
style: TextStyle(fontSize: 13, color: Colors.black54),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 14),
|
||||||
|
TextField(
|
||||||
|
controller: ctrl,
|
||||||
|
autofocus: true,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
labelText: 'Código / SKU',
|
||||||
|
prefixIcon: Icon(Icons.qr_code),
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
onSubmitted: (v) {
|
||||||
|
if (v.trim().isNotEmpty) Navigator.pop(ctx, v.trim());
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(onPressed: () => Navigator.pop(ctx), child: const Text('Cancelar')),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
final v = ctrl.text.trim();
|
||||||
|
if (v.isNotEmpty) Navigator.pop(ctx, v);
|
||||||
|
},
|
||||||
|
child: const Text('Buscar'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||||
|
import '../../theme/app_theme.dart';
|
||||||
|
|
||||||
|
class ScannerScreen extends StatefulWidget {
|
||||||
|
final String titulo;
|
||||||
|
const ScannerScreen({Key? key, this.titulo = 'Escanear código'}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ScannerScreen> createState() => _ScannerScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ScannerScreenState extends State<ScannerScreen> {
|
||||||
|
final _controller = MobileScannerController();
|
||||||
|
bool _scanned = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onDetect(Barcode barcode, MobileScannerArguments? args) {
|
||||||
|
if (_scanned || barcode.rawValue == null || barcode.rawValue!.isEmpty) return;
|
||||||
|
_scanned = true;
|
||||||
|
Navigator.pop(context, barcode.rawValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
appBar: AppBar(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
elevation: 0,
|
||||||
|
title: Text(widget.titulo),
|
||||||
|
actions: [
|
||||||
|
ValueListenableBuilder<TorchState>(
|
||||||
|
valueListenable: _controller.torchState,
|
||||||
|
builder: (_, state, __) => IconButton(
|
||||||
|
tooltip: state == TorchState.on ? 'Apagar linterna' : 'Encender linterna',
|
||||||
|
icon: Icon(
|
||||||
|
state == TorchState.on ? Icons.flash_on : Icons.flash_off,
|
||||||
|
color: state == TorchState.on ? Colors.yellow : Colors.white,
|
||||||
|
),
|
||||||
|
onPressed: _controller.toggleTorch,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ValueListenableBuilder<CameraFacing>(
|
||||||
|
valueListenable: _controller.cameraFacingState,
|
||||||
|
builder: (_, facing, __) => IconButton(
|
||||||
|
tooltip: 'Cambiar cámara',
|
||||||
|
icon: const Icon(Icons.cameraswitch, color: Colors.white),
|
||||||
|
onPressed: _controller.switchCamera,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
MobileScanner(
|
||||||
|
controller: _controller,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
onDetect: _onDetect,
|
||||||
|
),
|
||||||
|
CustomPaint(
|
||||||
|
painter: _ScanOverlayPainter(),
|
||||||
|
child: const SizedBox.expand(),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 56,
|
||||||
|
child: Column(
|
||||||
|
children: const [
|
||||||
|
Icon(Icons.qr_code_scanner, color: Colors.white38, size: 28),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
'Apunta al código QR o código de barras',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(color: Colors.white70, fontSize: 13),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ScanOverlayPainter extends CustomPainter {
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final frameSize = size.width * 0.72;
|
||||||
|
final left = (size.width - frameSize) / 2;
|
||||||
|
final top = (size.height - frameSize) / 2 - 40;
|
||||||
|
final frameRect = Rect.fromLTWH(left, top, frameSize, frameSize);
|
||||||
|
|
||||||
|
// Semi-transparent overlay with hole
|
||||||
|
final overlayPaint = Paint()..color = Colors.black.withOpacity(0.55);
|
||||||
|
final outer = Path()..addRect(Rect.fromLTWH(0, 0, size.width, size.height));
|
||||||
|
final inner = Path()..addRRect(RRect.fromRectAndRadius(frameRect, const Radius.circular(10)));
|
||||||
|
canvas.drawPath(Path.combine(PathOperation.difference, outer, inner), overlayPaint);
|
||||||
|
|
||||||
|
// Corner brackets
|
||||||
|
final bracketPaint = Paint()
|
||||||
|
..color = AppTheme.primaryColor
|
||||||
|
..style = PaintingStyle.stroke
|
||||||
|
..strokeWidth = 3.5
|
||||||
|
..strokeCap = StrokeCap.round;
|
||||||
|
|
||||||
|
const cl = 22.0; // corner length
|
||||||
|
final l = frameRect.left;
|
||||||
|
final t = frameRect.top;
|
||||||
|
final r = frameRect.right;
|
||||||
|
final b = frameRect.bottom;
|
||||||
|
|
||||||
|
// Top-left
|
||||||
|
canvas.drawLine(Offset(l, t + cl), Offset(l, t), bracketPaint);
|
||||||
|
canvas.drawLine(Offset(l, t), Offset(l + cl, t), bracketPaint);
|
||||||
|
// Top-right
|
||||||
|
canvas.drawLine(Offset(r - cl, t), Offset(r, t), bracketPaint);
|
||||||
|
canvas.drawLine(Offset(r, t), Offset(r, t + cl), bracketPaint);
|
||||||
|
// Bottom-left
|
||||||
|
canvas.drawLine(Offset(l, b - cl), Offset(l, b), bracketPaint);
|
||||||
|
canvas.drawLine(Offset(l, b), Offset(l + cl, b), bracketPaint);
|
||||||
|
// Bottom-right
|
||||||
|
canvas.drawLine(Offset(r - cl, b), Offset(r, b), bracketPaint);
|
||||||
|
canvas.drawLine(Offset(r, b), Offset(r, b - cl), bracketPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(_) => false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../models/notificacion.dart';
|
||||||
|
import '../widgets/notification_banner.dart';
|
||||||
|
|
||||||
|
class NotificationService extends ChangeNotifier {
|
||||||
|
final GlobalKey<NavigatorState> navigatorKey;
|
||||||
|
final List<Notificacion> _notifications = [];
|
||||||
|
|
||||||
|
NotificationService({required this.navigatorKey});
|
||||||
|
|
||||||
|
List<Notificacion> get notifications => List.unmodifiable(_notifications);
|
||||||
|
int get unreadCount => _notifications.where((n) => !n.leida).length;
|
||||||
|
|
||||||
|
void mostrar(Notificacion notif) {
|
||||||
|
_notifications.insert(0, notif);
|
||||||
|
notifyListeners();
|
||||||
|
_showBanner(notif);
|
||||||
|
}
|
||||||
|
|
||||||
|
void marcarTodasLeidas() {
|
||||||
|
for (final n in _notifications) {
|
||||||
|
n.leida = true;
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void marcarLeida(String id) {
|
||||||
|
final idx = _notifications.indexWhere((n) => n.id == id);
|
||||||
|
if (idx >= 0) {
|
||||||
|
_notifications[idx].leida = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void eliminar(String id) {
|
||||||
|
_notifications.removeWhere((n) => n.id == id);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showBanner(Notificacion notif) {
|
||||||
|
final overlay = navigatorKey.currentState?.overlay;
|
||||||
|
if (overlay == null) return;
|
||||||
|
OverlayEntry? entry;
|
||||||
|
entry = OverlayEntry(
|
||||||
|
builder: (_) => NotificationBanner(
|
||||||
|
notificacion: notif,
|
||||||
|
onDismiss: () => entry?.remove(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
overlay.insert(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Disparadores de conveniencia ─────────────────────────────
|
||||||
|
|
||||||
|
void notifPedidoConfirmado(String id, String cliente) {
|
||||||
|
mostrar(Notificacion(
|
||||||
|
id: '${DateTime.now().millisecondsSinceEpoch}',
|
||||||
|
tipo: TipoNotificacion.pedidoConfirmado,
|
||||||
|
titulo: 'Pedido confirmado',
|
||||||
|
cuerpo: '$id firmado y confirmado — $cliente',
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void notifParadaVisitada(String cliente) {
|
||||||
|
mostrar(Notificacion(
|
||||||
|
id: '${DateTime.now().millisecondsSinceEpoch}',
|
||||||
|
tipo: TipoNotificacion.pedidoEntregado,
|
||||||
|
titulo: 'Visita completada',
|
||||||
|
cuerpo: 'Parada en $cliente marcada como visitada',
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void notifStockBajo(String producto, int stock) {
|
||||||
|
mostrar(Notificacion(
|
||||||
|
id: '${DateTime.now().millisecondsSinceEpoch}',
|
||||||
|
tipo: TipoNotificacion.stockBajo,
|
||||||
|
titulo: 'Stock bajo',
|
||||||
|
cuerpo: '$producto — solo $stock unidades disponibles',
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> dispararDemo() async {
|
||||||
|
final base = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
final demos = [
|
||||||
|
Notificacion(
|
||||||
|
id: '${base}_1',
|
||||||
|
tipo: TipoNotificacion.paradaProxima,
|
||||||
|
titulo: 'Próxima parada en 15 min',
|
||||||
|
cuerpo: 'InfoSystems La Paz — Av. Mariscal Santa Cruz 1250',
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
),
|
||||||
|
Notificacion(
|
||||||
|
id: '${base}_2',
|
||||||
|
tipo: TipoNotificacion.stockBajo,
|
||||||
|
titulo: 'Stock bajo',
|
||||||
|
cuerpo: 'Router TP-Link AX3000 — solo 3 unidades disponibles',
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
),
|
||||||
|
Notificacion(
|
||||||
|
id: '${base}_3',
|
||||||
|
tipo: TipoNotificacion.pedidoConfirmado,
|
||||||
|
titulo: 'Pedido confirmado',
|
||||||
|
cuerpo: 'TTC-0047 firmado por TechZone Bolivia — Bs. 24,500.00',
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
),
|
||||||
|
Notificacion(
|
||||||
|
id: '${base}_4',
|
||||||
|
tipo: TipoNotificacion.metaVentas,
|
||||||
|
titulo: '¡Meta del día alcanzada!',
|
||||||
|
cuerpo: 'Superaste Bs. 15,000 en ventas. ¡Excelente trabajo, Roberto!',
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
),
|
||||||
|
Notificacion(
|
||||||
|
id: '${base}_5',
|
||||||
|
tipo: TipoNotificacion.recordatorio,
|
||||||
|
titulo: 'Recordatorio de visita',
|
||||||
|
cuerpo: 'Gobernación La Paz — contrato de renovación anual pendiente',
|
||||||
|
fecha: DateTime.now(),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (final n in demos) {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 950));
|
||||||
|
mostrar(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AppTheme {
|
||||||
|
static const primaryColor = Color(0xFF1E40AF);
|
||||||
|
static const accentColor = Color(0xFFF97316);
|
||||||
|
static const successColor = Color(0xFF16A34A);
|
||||||
|
static const warningColor = Color(0xFFD97706);
|
||||||
|
static const dangerColor = Color(0xFFDC2626);
|
||||||
|
static const bgColor = Color(0xFFF1F5F9);
|
||||||
|
static const cardColor = Colors.white;
|
||||||
|
static const textPrimary = Color(0xFF1E293B);
|
||||||
|
static const textSecondary = Color(0xFF64748B);
|
||||||
|
|
||||||
|
static ThemeData get light => ThemeData(
|
||||||
|
primaryColor: primaryColor,
|
||||||
|
colorScheme: ColorScheme.fromSwatch().copyWith(
|
||||||
|
primary: primaryColor,
|
||||||
|
secondary: accentColor,
|
||||||
|
),
|
||||||
|
scaffoldBackgroundColor: bgColor,
|
||||||
|
appBarTheme: const AppBarTheme(
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
elevation: 0,
|
||||||
|
centerTitle: false,
|
||||||
|
),
|
||||||
|
cardTheme: CardTheme(
|
||||||
|
color: cardColor,
|
||||||
|
elevation: 2,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||||
|
),
|
||||||
|
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
primary: primaryColor,
|
||||||
|
onPrimary: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
|
||||||
|
elevation: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.white,
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: const BorderSide(color: Color(0xFFCBD5E1)),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: const BorderSide(color: Color(0xFFCBD5E1)),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
borderSide: const BorderSide(color: primaryColor, width: 2),
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||||
|
),
|
||||||
|
textTheme: const TextTheme(
|
||||||
|
headline5: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: textPrimary),
|
||||||
|
headline6: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: textPrimary),
|
||||||
|
subtitle1: TextStyle(fontSize: 16, fontWeight: FontWeight.w500, color: textPrimary),
|
||||||
|
subtitle2: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: textSecondary),
|
||||||
|
bodyText1: TextStyle(fontSize: 14, color: textPrimary),
|
||||||
|
bodyText2: TextStyle(fontSize: 13, color: textSecondary),
|
||||||
|
caption: TextStyle(fontSize: 12, color: textSecondary),
|
||||||
|
),
|
||||||
|
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
selectedItemColor: primaryColor,
|
||||||
|
unselectedItemColor: Color(0xFF94A3B8),
|
||||||
|
selectedLabelStyle: TextStyle(fontWeight: FontWeight.w600, fontSize: 11),
|
||||||
|
unselectedLabelStyle: TextStyle(fontSize: 11),
|
||||||
|
showUnselectedLabels: true,
|
||||||
|
type: BottomNavigationBarType.fixed,
|
||||||
|
elevation: 8,
|
||||||
|
),
|
||||||
|
chipTheme: ChipThemeData(
|
||||||
|
backgroundColor: const Color(0xFFE2E8F0),
|
||||||
|
selectedColor: primaryColor,
|
||||||
|
labelStyle: const TextStyle(fontSize: 12),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
static Color estadoColor(String estado) {
|
||||||
|
switch (estado.toLowerCase()) {
|
||||||
|
case 'confirmado': return successColor;
|
||||||
|
case 'entregado': return const Color(0xFF0891B2);
|
||||||
|
case 'cancelado': return dangerColor;
|
||||||
|
default: return warningColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../models/notificacion.dart';
|
||||||
|
|
||||||
|
class NotificationBanner extends StatefulWidget {
|
||||||
|
final Notificacion notificacion;
|
||||||
|
final VoidCallback onDismiss;
|
||||||
|
|
||||||
|
const NotificationBanner({
|
||||||
|
Key? key,
|
||||||
|
required this.notificacion,
|
||||||
|
required this.onDismiss,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<NotificationBanner> createState() => _NotificationBannerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NotificationBannerState extends State<NotificationBanner>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late AnimationController _ctrl;
|
||||||
|
late Animation<Offset> _slide;
|
||||||
|
late Animation<double> _fade;
|
||||||
|
bool _dismissing = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_ctrl = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 320),
|
||||||
|
);
|
||||||
|
_slide = Tween<Offset>(
|
||||||
|
begin: const Offset(0, -1.2),
|
||||||
|
end: Offset.zero,
|
||||||
|
).animate(CurvedAnimation(parent: _ctrl, curve: Curves.easeOutBack));
|
||||||
|
_fade = CurvedAnimation(parent: _ctrl, curve: Curves.easeOut);
|
||||||
|
|
||||||
|
_ctrl.forward();
|
||||||
|
Future.delayed(const Duration(milliseconds: 3800), _startDismiss);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_ctrl.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _startDismiss() async {
|
||||||
|
if (_dismissing || !mounted) return;
|
||||||
|
_dismissing = true;
|
||||||
|
_ctrl.reverse();
|
||||||
|
await Future.delayed(const Duration(milliseconds: 320));
|
||||||
|
widget.onDismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final notif = widget.notificacion;
|
||||||
|
final color = notif.tipo.color;
|
||||||
|
|
||||||
|
return Positioned(
|
||||||
|
top: MediaQuery.of(context).padding.top + 10,
|
||||||
|
left: 14,
|
||||||
|
right: 14,
|
||||||
|
child: SlideTransition(
|
||||||
|
position: _slide,
|
||||||
|
child: FadeTransition(
|
||||||
|
opacity: _fade,
|
||||||
|
child: Material(
|
||||||
|
elevation: 8,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
shadowColor: color.withOpacity(0.3),
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: _startDismiss,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(color: color, width: 4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(12, 12, 8, 12),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color.withOpacity(0.12),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: Icon(notif.tipo.icono, color: color, size: 18),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
notif.titulo,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Color(0xFF0F172A),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
'Ahora',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
color: Colors.grey.shade500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 3),
|
||||||
|
Text(
|
||||||
|
notif.cuerpo,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Color(0xFF475569),
|
||||||
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: _startDismiss,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 4),
|
||||||
|
child: Icon(Icons.close, size: 16, color: Colors.grey.shade400),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../models/parada_ruta.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
|
||||||
|
class RouteMapPainter extends CustomPainter {
|
||||||
|
final List<ParadaRuta> paradas;
|
||||||
|
|
||||||
|
RouteMapPainter(this.paradas);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
_drawMapBackground(canvas, size);
|
||||||
|
_drawGrid(canvas, size);
|
||||||
|
_drawRoute(canvas, size);
|
||||||
|
_drawMarkers(canvas, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _drawMapBackground(Canvas canvas, Size size) {
|
||||||
|
final bgPaint = Paint()..color = const Color(0xFFEEF2FF);
|
||||||
|
canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), bgPaint);
|
||||||
|
|
||||||
|
// blocks
|
||||||
|
final blockPaint = Paint()..color = const Color(0xFFDDD6FE).withOpacity(0.4);
|
||||||
|
final blocks = [
|
||||||
|
Rect.fromLTWH(size.width * 0.05, size.height * 0.08, size.width * 0.25, size.height * 0.15),
|
||||||
|
Rect.fromLTWH(size.width * 0.40, size.height * 0.05, size.width * 0.20, size.height * 0.18),
|
||||||
|
Rect.fromLTWH(size.width * 0.70, size.height * 0.10, size.width * 0.22, size.height * 0.12),
|
||||||
|
Rect.fromLTWH(size.width * 0.10, size.height * 0.35, size.width * 0.18, size.height * 0.20),
|
||||||
|
Rect.fromLTWH(size.width * 0.35, size.height * 0.30, size.width * 0.28, size.height * 0.22),
|
||||||
|
Rect.fromLTWH(size.width * 0.70, size.height * 0.30, size.width * 0.22, size.height * 0.25),
|
||||||
|
Rect.fromLTWH(size.width * 0.05, size.height * 0.62, size.width * 0.30, size.height * 0.18),
|
||||||
|
Rect.fromLTWH(size.width * 0.42, size.height * 0.60, size.width * 0.22, size.height * 0.20),
|
||||||
|
Rect.fromLTWH(size.width * 0.72, size.height * 0.62, size.width * 0.20, size.height * 0.18),
|
||||||
|
];
|
||||||
|
for (final r in blocks) {
|
||||||
|
canvas.drawRRect(
|
||||||
|
RRect.fromRectAndRadius(r, const Radius.circular(4)),
|
||||||
|
blockPaint,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// roads
|
||||||
|
final roadPaint = Paint()
|
||||||
|
..color = Colors.white
|
||||||
|
..strokeWidth = 8
|
||||||
|
..strokeCap = StrokeCap.round;
|
||||||
|
|
||||||
|
final roads = [
|
||||||
|
[Offset(0, size.height * 0.28), Offset(size.width, size.height * 0.28)],
|
||||||
|
[Offset(0, size.height * 0.57), Offset(size.width, size.height * 0.57)],
|
||||||
|
[Offset(size.width * 0.32, 0), Offset(size.width * 0.32, size.height)],
|
||||||
|
[Offset(size.width * 0.65, 0), Offset(size.width * 0.65, size.height)],
|
||||||
|
];
|
||||||
|
for (final road in roads) {
|
||||||
|
canvas.drawLine(road[0], road[1], roadPaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _drawGrid(Canvas canvas, Size size) {
|
||||||
|
final gridPaint = Paint()
|
||||||
|
..color = Colors.white.withOpacity(0.6)
|
||||||
|
..strokeWidth = 1;
|
||||||
|
for (double x = 0; x < size.width; x += size.width / 8) {
|
||||||
|
canvas.drawLine(Offset(x, 0), Offset(x, size.height), gridPaint);
|
||||||
|
}
|
||||||
|
for (double y = 0; y < size.height; y += size.height / 6) {
|
||||||
|
canvas.drawLine(Offset(0, y), Offset(size.width, y), gridPaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Offset> _getPositions(Size size) {
|
||||||
|
// Fixed visual positions for the 6 stops
|
||||||
|
return [
|
||||||
|
Offset(size.width * 0.18, size.height * 0.20),
|
||||||
|
Offset(size.width * 0.50, size.height * 0.15),
|
||||||
|
Offset(size.width * 0.80, size.height * 0.22),
|
||||||
|
Offset(size.width * 0.75, size.height * 0.50),
|
||||||
|
Offset(size.width * 0.45, size.height * 0.72),
|
||||||
|
Offset(size.width * 0.15, size.height * 0.68),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
void _drawRoute(Canvas canvas, Size size) {
|
||||||
|
if (paradas.isEmpty) return;
|
||||||
|
final positions = _getPositions(size);
|
||||||
|
final count = paradas.length < positions.length ? paradas.length : positions.length;
|
||||||
|
|
||||||
|
// dashed line for future stops
|
||||||
|
final donePaint = Paint()
|
||||||
|
..color = AppTheme.primaryColor.withOpacity(0.7)
|
||||||
|
..strokeWidth = 2.5
|
||||||
|
..strokeCap = StrokeCap.round
|
||||||
|
..style = PaintingStyle.stroke;
|
||||||
|
|
||||||
|
final pendingPaint = Paint()
|
||||||
|
..color = AppTheme.primaryColor.withOpacity(0.35)
|
||||||
|
..strokeWidth = 2
|
||||||
|
..strokeCap = StrokeCap.round
|
||||||
|
..style = PaintingStyle.stroke;
|
||||||
|
|
||||||
|
for (int i = 0; i < count - 1; i++) {
|
||||||
|
final isVisited = paradas[i].estado == EstadoParada.visitado &&
|
||||||
|
paradas[i + 1].estado == EstadoParada.visitado;
|
||||||
|
canvas.drawLine(positions[i], positions[i + 1],
|
||||||
|
isVisited ? donePaint : pendingPaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _drawMarkers(Canvas canvas, Size size) {
|
||||||
|
if (paradas.isEmpty) return;
|
||||||
|
final positions = _getPositions(size);
|
||||||
|
final count = paradas.length < positions.length ? paradas.length : positions.length;
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
final parada = paradas[i];
|
||||||
|
final pos = positions[i];
|
||||||
|
final isVisited = parada.estado == EstadoParada.visitado;
|
||||||
|
final isCurrent = parada.estado == EstadoParada.pendiente &&
|
||||||
|
(i == 0 || paradas[i - 1].estado == EstadoParada.visitado);
|
||||||
|
|
||||||
|
final color = isVisited
|
||||||
|
? AppTheme.successColor
|
||||||
|
: isCurrent
|
||||||
|
? AppTheme.accentColor
|
||||||
|
: AppTheme.primaryColor.withOpacity(0.5);
|
||||||
|
|
||||||
|
// shadow
|
||||||
|
final shadowPaint = Paint()
|
||||||
|
..color = Colors.black.withOpacity(0.15)
|
||||||
|
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 3);
|
||||||
|
canvas.drawCircle(pos + const Offset(0, 2), isCurrent ? 16 : 13, shadowPaint);
|
||||||
|
|
||||||
|
// outer ring for current
|
||||||
|
if (isCurrent) {
|
||||||
|
final ringPaint = Paint()
|
||||||
|
..color = AppTheme.accentColor.withOpacity(0.25)
|
||||||
|
..style = PaintingStyle.fill;
|
||||||
|
canvas.drawCircle(pos, 22, ringPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
// marker body
|
||||||
|
final markerPaint = Paint()..color = color;
|
||||||
|
canvas.drawCircle(pos, isCurrent ? 16 : 13, markerPaint);
|
||||||
|
|
||||||
|
// white inner
|
||||||
|
final innerPaint = Paint()..color = Colors.white;
|
||||||
|
canvas.drawCircle(pos, isCurrent ? 9 : 7, innerPaint);
|
||||||
|
|
||||||
|
// number
|
||||||
|
final textPainter = TextPainter(
|
||||||
|
text: TextSpan(
|
||||||
|
text: '${i + 1}',
|
||||||
|
style: TextStyle(
|
||||||
|
color: color,
|
||||||
|
fontSize: isCurrent ? 10 : 8,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
)..layout();
|
||||||
|
textPainter.paint(
|
||||||
|
canvas,
|
||||||
|
pos - Offset(textPainter.width / 2, textPainter.height / 2),
|
||||||
|
);
|
||||||
|
|
||||||
|
// label chip
|
||||||
|
_drawLabel(canvas, pos, parada.cliente.nombre.split(' ').first, color, isCurrent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// current position indicator (GPS dot)
|
||||||
|
if (count > 0) {
|
||||||
|
final currentIndex = paradas.indexWhere((p) => p.estado == EstadoParada.pendiente);
|
||||||
|
if (currentIndex >= 0 && currentIndex < positions.length) {
|
||||||
|
final gpsPos = positions[currentIndex] + const Offset(-24, -24);
|
||||||
|
final gpsPaint = Paint()..color = Colors.blue;
|
||||||
|
canvas.drawCircle(gpsPos, 7, gpsPaint);
|
||||||
|
final gpsBorderPaint = Paint()
|
||||||
|
..color = Colors.white
|
||||||
|
..style = PaintingStyle.stroke
|
||||||
|
..strokeWidth = 2;
|
||||||
|
canvas.drawCircle(gpsPos, 7, gpsBorderPaint);
|
||||||
|
final gpsPulsePaint = Paint()
|
||||||
|
..color = Colors.blue.withOpacity(0.25);
|
||||||
|
canvas.drawCircle(gpsPos, 12, gpsPulsePaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _drawLabel(Canvas canvas, Offset pos, String text, Color color, bool isCurrent) {
|
||||||
|
final tp = TextPainter(
|
||||||
|
text: TextSpan(
|
||||||
|
text: text,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: AppTheme.textPrimary,
|
||||||
|
fontSize: 9,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
)..layout();
|
||||||
|
|
||||||
|
const padding = 4.0;
|
||||||
|
final chipW = tp.width + padding * 2;
|
||||||
|
const chipH = 16.0;
|
||||||
|
final chipOffset = Offset(pos.dx - chipW / 2, pos.dy + (isCurrent ? 20 : 17));
|
||||||
|
|
||||||
|
final chipBg = Paint()..color = Colors.white.withOpacity(0.9);
|
||||||
|
final chipBorder = Paint()
|
||||||
|
..color = color.withOpacity(0.5)
|
||||||
|
..style = PaintingStyle.stroke
|
||||||
|
..strokeWidth = 1;
|
||||||
|
|
||||||
|
final chipRect = RRect.fromRectAndRadius(
|
||||||
|
Rect.fromLTWH(chipOffset.dx, chipOffset.dy, chipW, chipH),
|
||||||
|
const Radius.circular(4),
|
||||||
|
);
|
||||||
|
canvas.drawRRect(chipRect, chipBg);
|
||||||
|
canvas.drawRRect(chipRect, chipBorder);
|
||||||
|
tp.paint(canvas, chipOffset + const Offset(padding, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(RouteMapPainter oldDelegate) => true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
|
||||||
|
class SignaturePad extends StatefulWidget {
|
||||||
|
final void Function(List<List<Offset>> strokes) onChanged;
|
||||||
|
|
||||||
|
const SignaturePad({Key? key, required this.onChanged}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SignaturePad> createState() => SignaturePadState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SignaturePadState extends State<SignaturePad> {
|
||||||
|
final List<List<Offset>> _strokes = [];
|
||||||
|
List<Offset> _current = [];
|
||||||
|
|
||||||
|
bool get isEmpty => _strokes.isEmpty;
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
setState(() {
|
||||||
|
_strokes.clear();
|
||||||
|
_current = [];
|
||||||
|
});
|
||||||
|
widget.onChanged([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return GestureDetector(
|
||||||
|
onPanStart: (details) {
|
||||||
|
setState(() {
|
||||||
|
_current = [details.localPosition];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onPanUpdate: (details) {
|
||||||
|
setState(() {
|
||||||
|
_current = [..._current, details.localPosition];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onPanEnd: (_) {
|
||||||
|
if (_current.isNotEmpty) {
|
||||||
|
setState(() {
|
||||||
|
_strokes.add(List.from(_current));
|
||||||
|
_current = [];
|
||||||
|
});
|
||||||
|
widget.onChanged(List.from(_strokes));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: CustomPaint(
|
||||||
|
painter: _SignaturePainter(strokes: _strokes, current: _current),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(color: const Color(0xFFCBD5E1), width: 1.5),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SignaturePainter extends CustomPainter {
|
||||||
|
final List<List<Offset>> strokes;
|
||||||
|
final List<Offset> current;
|
||||||
|
|
||||||
|
_SignaturePainter({required this.strokes, required this.current});
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
final paint = Paint()
|
||||||
|
..color = AppTheme.primaryColor
|
||||||
|
..strokeWidth = 2.5
|
||||||
|
..strokeCap = StrokeCap.round
|
||||||
|
..strokeJoin = StrokeJoin.round
|
||||||
|
..style = PaintingStyle.stroke;
|
||||||
|
|
||||||
|
for (final stroke in strokes) {
|
||||||
|
_drawStroke(canvas, stroke, paint);
|
||||||
|
}
|
||||||
|
if (current.isNotEmpty) {
|
||||||
|
_drawStroke(canvas, current, paint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _drawStroke(Canvas canvas, List<Offset> points, Paint paint) {
|
||||||
|
if (points.length < 2) return;
|
||||||
|
final path = Path()..moveTo(points[0].dx, points[0].dy);
|
||||||
|
for (int i = 1; i < points.length - 1; i++) {
|
||||||
|
final mid = Offset(
|
||||||
|
(points[i].dx + points[i + 1].dx) / 2,
|
||||||
|
(points[i].dy + points[i + 1].dy) / 2,
|
||||||
|
);
|
||||||
|
path.quadraticBezierTo(points[i].dx, points[i].dy, mid.dx, mid.dy);
|
||||||
|
}
|
||||||
|
path.lineTo(points.last.dx, points.last.dy);
|
||||||
|
canvas.drawPath(path, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(_SignaturePainter old) => true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import '../theme/app_theme.dart';
|
||||||
|
|
||||||
|
class StatCard extends StatelessWidget {
|
||||||
|
final String titulo;
|
||||||
|
final String valor;
|
||||||
|
final String subtitulo;
|
||||||
|
final IconData icono;
|
||||||
|
final Color color;
|
||||||
|
|
||||||
|
const StatCard({
|
||||||
|
Key? key,
|
||||||
|
required this.titulo,
|
||||||
|
required this.valor,
|
||||||
|
required this.subtitulo,
|
||||||
|
required this.icono,
|
||||||
|
required this.color,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppTheme.cardColor,
|
||||||
|
borderRadius: BorderRadius.circular(14),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: color.withOpacity(0.15),
|
||||||
|
blurRadius: 10,
|
||||||
|
offset: const Offset(0, 4),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
titulo,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: AppTheme.textSecondary,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color.withOpacity(0.12),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Icon(icono, color: color, size: 18),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
valor,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
subtitulo,
|
||||||
|
style: const TextStyle(fontSize: 11, color: AppTheme.textSecondary),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
flutter/ephemeral
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
# Project-level configuration.
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(runner LANGUAGES CXX)
|
||||||
|
|
||||||
|
# The name of the executable created for the application. Change this to change
|
||||||
|
# the on-disk name of your application.
|
||||||
|
set(BINARY_NAME "pedidos_app")
|
||||||
|
# The unique GTK application identifier for this application. See:
|
||||||
|
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
|
||||||
|
set(APPLICATION_ID "com.pedidosapp.pedidos_app")
|
||||||
|
|
||||||
|
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||||
|
# versions of CMake.
|
||||||
|
cmake_policy(SET CMP0063 NEW)
|
||||||
|
|
||||||
|
# Load bundled libraries from the lib/ directory relative to the binary.
|
||||||
|
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
||||||
|
|
||||||
|
# Root filesystem for cross-building.
|
||||||
|
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
|
||||||
|
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
|
||||||
|
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Define build configuration options.
|
||||||
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
set(CMAKE_BUILD_TYPE "Debug" CACHE
|
||||||
|
STRING "Flutter build mode" FORCE)
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||||
|
"Debug" "Profile" "Release")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Compilation settings that should be applied to most targets.
|
||||||
|
#
|
||||||
|
# Be cautious about adding new options here, as plugins use this function by
|
||||||
|
# default. In most cases, you should add new options to specific targets instead
|
||||||
|
# of modifying this function.
|
||||||
|
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||||
|
target_compile_features(${TARGET} PUBLIC cxx_std_14)
|
||||||
|
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||||
|
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||||
|
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Flutter library and tool build rules.
|
||||||
|
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||||
|
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||||
|
|
||||||
|
# System-level dependencies.
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||||
|
|
||||||
|
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
|
||||||
|
|
||||||
|
# Define the application target. To change its name, change BINARY_NAME above,
|
||||||
|
# not the value here, or `flutter run` will no longer work.
|
||||||
|
#
|
||||||
|
# Any new source files that you add to the application should be added here.
|
||||||
|
add_executable(${BINARY_NAME}
|
||||||
|
"main.cc"
|
||||||
|
"my_application.cc"
|
||||||
|
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Apply the standard set of build settings. This can be removed for applications
|
||||||
|
# that need different build settings.
|
||||||
|
apply_standard_settings(${BINARY_NAME})
|
||||||
|
|
||||||
|
# Add dependency libraries. Add any application-specific dependencies here.
|
||||||
|
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
|
||||||
|
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
|
||||||
|
|
||||||
|
# Run the Flutter tool portions of the build. This must not be removed.
|
||||||
|
add_dependencies(${BINARY_NAME} flutter_assemble)
|
||||||
|
|
||||||
|
# Only the install-generated bundle's copy of the executable will launch
|
||||||
|
# correctly, since the resources must in the right relative locations. To avoid
|
||||||
|
# people trying to run the unbundled copy, put it in a subdirectory instead of
|
||||||
|
# the default top-level location.
|
||||||
|
set_target_properties(${BINARY_NAME}
|
||||||
|
PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Generated plugin build rules, which manage building the plugins and adding
|
||||||
|
# them to the application.
|
||||||
|
include(flutter/generated_plugins.cmake)
|
||||||
|
|
||||||
|
|
||||||
|
# === Installation ===
|
||||||
|
# By default, "installing" just makes a relocatable bundle in the build
|
||||||
|
# directory.
|
||||||
|
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
|
||||||
|
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Start with a clean build bundle directory every time.
|
||||||
|
install(CODE "
|
||||||
|
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
|
||||||
|
" COMPONENT Runtime)
|
||||||
|
|
||||||
|
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
|
||||||
|
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
|
||||||
|
|
||||||
|
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
|
||||||
|
COMPONENT Runtime)
|
||||||
|
|
||||||
|
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
|
||||||
|
COMPONENT Runtime)
|
||||||
|
|
||||||
|
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||||
|
COMPONENT Runtime)
|
||||||
|
|
||||||
|
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
|
||||||
|
install(FILES "${bundled_library}"
|
||||||
|
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||||
|
COMPONENT Runtime)
|
||||||
|
endforeach(bundled_library)
|
||||||
|
|
||||||
|
# Fully re-copy the assets directory on each build to avoid having stale files
|
||||||
|
# from a previous install.
|
||||||
|
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
||||||
|
install(CODE "
|
||||||
|
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
|
||||||
|
" COMPONENT Runtime)
|
||||||
|
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
|
||||||
|
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
|
||||||
|
|
||||||
|
# Install the AOT library on non-Debug builds only.
|
||||||
|
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
|
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
|
||||||
|
COMPONENT Runtime)
|
||||||
|
endif()
|
||||||