Alterações visuais, melhorias em envio de mensagem
This commit is contained in:
@@ -1,3 +1,15 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
// Versões estáveis e compatíveis com Flutter 3.x
|
||||||
|
classpath("com.android.tools.build:gradle:7.4.2")
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#Fri Mar 13 16:43:00 WET 2026
|
#Sat Mar 14 16:08:23 WET 2026
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
val flutterSdkPath =
|
val flutterSdkPath = run {
|
||||||
run {
|
val properties = java.util.Properties()
|
||||||
val properties = java.util.Properties()
|
file("local.properties").inputStream().use { properties.load(it) }
|
||||||
file("local.properties").inputStream().use { properties.load(it) }
|
properties.getProperty("flutter.sdk") ?: throw GradleException("Flutter SDK not found in local.properties")
|
||||||
val flutterSdkPath = properties.getProperty("flutter.sdk")
|
}
|
||||||
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
|
|
||||||
flutterSdkPath
|
|
||||||
}
|
|
||||||
|
|
||||||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
|
||||||
|
|
||||||
@@ -17,10 +14,11 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No ficheiro android/settings.gradle
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||||
id("com.android.application") version "8.11.1" apply false
|
id("com.android.application") version "8.3.0" apply false
|
||||||
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
|
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
include(":app")
|
include(":app")
|
||||||
|
|||||||
BIN
assets/logo.png
Normal file
BIN
assets/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
@@ -2,6 +2,7 @@ import 'dart:ui';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
class ChatScreen extends StatefulWidget {
|
class ChatScreen extends StatefulWidget {
|
||||||
const ChatScreen({super.key});
|
const ChatScreen({super.key});
|
||||||
@@ -22,235 +23,168 @@ class _ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
|||||||
final TextEditingController _textController = TextEditingController();
|
final TextEditingController _textController = TextEditingController();
|
||||||
final ScrollController _scrollController = ScrollController();
|
final ScrollController _scrollController = ScrollController();
|
||||||
bool _isTyping = false;
|
bool _isTyping = false;
|
||||||
|
late AnimationController _typingController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_typingController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(milliseconds: 1200),
|
||||||
|
)..repeat();
|
||||||
|
|
||||||
|
Timer(const Duration(seconds: 2), () => _checkAvailableModels());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _checkAvailableModels() async {
|
||||||
|
try {
|
||||||
|
final response = await http.get(
|
||||||
|
Uri.parse('http://89.114.196.110:11434/api/tags'),
|
||||||
|
).timeout(const Duration(seconds: 15));
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final data = jsonDecode(response.body);
|
||||||
|
print("Modelos ok");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("Erro ao listar modelos: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_typingController.dispose();
|
||||||
|
_textController.dispose();
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Função para limpar o chat
|
||||||
|
void _clearChat() {
|
||||||
|
setState(() {
|
||||||
|
_messages.clear();
|
||||||
|
_isTyping = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _handleSubmitted(String text) async {
|
Future<void> _handleSubmitted(String text) async {
|
||||||
if (text.trim().isEmpty) return;
|
// BLOQUEIO: Se já estiver a escrever (isTyping), ignora o clique
|
||||||
|
if (text.trim().isEmpty || _isTyping) return;
|
||||||
|
|
||||||
_textController.clear();
|
_textController.clear();
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_messages.insert(0, ChatMessage(text: text));
|
_messages.insert(0, ChatMessage(text: text));
|
||||||
_isTyping = true;
|
_isTyping = true; // Ativa o bloqueio
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Faz o pedido para o IP usando o formato compatível com OpenAI
|
final url = Uri.parse('http://89.114.196.110:11434/v1/chat/completions');
|
||||||
|
|
||||||
final response = await http
|
final response = await http
|
||||||
.post(
|
.post(
|
||||||
Uri.parse('http://192.168.60.134:11434/v1/chat/completions'),
|
url,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {
|
||||||
body: jsonEncode({
|
'Content-Type': 'application/json',
|
||||||
'model': 'qwen3:4b', // Um modelo disponível no servidor
|
'Accept': 'application/json',
|
||||||
'messages': [
|
},
|
||||||
{'role': 'user', 'content': text},
|
body: jsonEncode({
|
||||||
],
|
'model': 'tinyllama',
|
||||||
'stream': false,
|
'messages': [{'role': 'user', 'content': text}],
|
||||||
}),
|
'stream': false,
|
||||||
)
|
}),
|
||||||
.timeout(const Duration(seconds: 30));
|
)
|
||||||
|
.timeout(const Duration(seconds: 60));
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final data = jsonDecode(response.body);
|
final data = jsonDecode(response.body);
|
||||||
final reply =
|
final reply = data['choices'][0]['message']['content'] ?? 'Sem resposta.';
|
||||||
data['choices'][0]['message']['content'] ??
|
|
||||||
'Sem resposta do modelo.';
|
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isTyping = false;
|
_isTyping = false; // Liberta o bloqueio
|
||||||
_messages.insert(0, ChatMessage(text: reply, isAssistant: true));
|
_messages.insert(0, ChatMessage(text: reply, isAssistant: true));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw Exception(
|
throw Exception('Erro ${response.statusCode}');
|
||||||
'Erro no servidor: HTTP ${response.statusCode} - ${response.body}',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isTyping = false;
|
_isTyping = false; // Liberta o bloqueio mesmo em caso de erro
|
||||||
_messages.insert(
|
_messages.insert(
|
||||||
0,
|
0,
|
||||||
ChatMessage(
|
ChatMessage(text: "Erro: $e", isAssistant: true),
|
||||||
text:
|
|
||||||
"Não foi possível comunicar com o modelo.\nVerifique se o IP está acessível.\nDetalhes: $e",
|
|
||||||
isAssistant: true,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ... (Mantenha _buildMessage, _buildAvatar, _buildTypingIndicator e _buildAnimatedDot iguais)
|
||||||
Widget _buildMessage(ChatMessage message) {
|
Widget _buildMessage(ChatMessage message) {
|
||||||
bool isAssistant = message.isAssistant;
|
bool isAssistant = message.isAssistant;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: isAssistant
|
mainAxisAlignment: isAssistant ? MainAxisAlignment.start : MainAxisAlignment.end,
|
||||||
? MainAxisAlignment.start
|
|
||||||
: MainAxisAlignment.end,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (isAssistant)
|
if (isAssistant) _buildAvatar(Icons.auto_awesome),
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(right: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
gradient: const LinearGradient(
|
|
||||||
colors: [Color(0xFF8ad5c9), Color(0xFF57a7ed)], // Mint & Blue
|
|
||||||
begin: Alignment.topLeft,
|
|
||||||
end: Alignment.bottomRight,
|
|
||||||
),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: const Color(0xFF8ad5c9).withOpacity(0.4),
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, 4),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: const CircleAvatar(
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
radius: 16,
|
|
||||||
child: Icon(Icons.auto_awesome, color: Colors.white, size: 18),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Flexible(
|
Flexible(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 14.0),
|
||||||
horizontal: 20.0,
|
|
||||||
vertical: 14.0,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: isAssistant
|
gradient: isAssistant
|
||||||
? const LinearGradient(
|
? const LinearGradient(colors: [Color(0xFFF1F5F9), Color(0xFFE2E8F0)])
|
||||||
colors: [
|
: const LinearGradient(colors: [Color(0xFF8ad5c9), Color(0xFF57a7ed)]),
|
||||||
Color(0xFFF1F5F9),
|
|
||||||
Color(0xFFE2E8F0),
|
|
||||||
], // Light bubbles
|
|
||||||
begin: Alignment.topLeft,
|
|
||||||
end: Alignment.bottomRight,
|
|
||||||
)
|
|
||||||
: const LinearGradient(
|
|
||||||
colors: [
|
|
||||||
Color(0xFF8ad5c9),
|
|
||||||
Color(0xFF57a7ed),
|
|
||||||
], // Mint & Blue bubbles
|
|
||||||
begin: Alignment.centerLeft,
|
|
||||||
end: Alignment.centerRight,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topLeft: const Radius.circular(20),
|
topLeft: const Radius.circular(20),
|
||||||
topRight: const Radius.circular(20),
|
topRight: const Radius.circular(20),
|
||||||
bottomLeft: Radius.circular(isAssistant ? 4 : 20),
|
bottomLeft: Radius.circular(isAssistant ? 4 : 20),
|
||||||
bottomRight: Radius.circular(isAssistant ? 20 : 4),
|
bottomRight: Radius.circular(isAssistant ? 20 : 4),
|
||||||
),
|
),
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.2),
|
|
||||||
blurRadius: 10,
|
|
||||||
offset: const Offset(0, 4),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
border: Border.all(
|
|
||||||
color: isAssistant
|
|
||||||
? Colors.black.withOpacity(0.05)
|
|
||||||
: Colors.transparent,
|
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
message.text,
|
message.text,
|
||||||
style: TextStyle(
|
style: TextStyle(color: isAssistant ? Colors.black87 : Colors.white),
|
||||||
color: isAssistant ? Colors.black87 : Colors.white,
|
|
||||||
fontSize: 15,
|
|
||||||
height: 1.4,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isAssistant)
|
if (!isAssistant) _buildAvatar(Icons.person),
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(left: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
gradient: const LinearGradient(
|
|
||||||
colors: [
|
|
||||||
Color(0xFF57a7ed),
|
|
||||||
Color(0xFF3A8BD1),
|
|
||||||
], // User avatar gradient
|
|
||||||
begin: Alignment.topLeft,
|
|
||||||
end: Alignment.bottomRight,
|
|
||||||
),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: const Color(0xFF57a7ed).withOpacity(0.3),
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, 4),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: const CircleAvatar(
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
radius: 16,
|
|
||||||
child: Icon(Icons.person, color: Colors.white, size: 18),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildAvatar(IconData icon) {
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.only(left: icon == Icons.person ? 12 : 0, right: icon == Icons.auto_awesome ? 12 : 0),
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: LinearGradient(colors: [Color(0xFF8ad5c9), Color(0xFF57a7ed)]),
|
||||||
|
),
|
||||||
|
child: CircleAvatar(backgroundColor: Colors.transparent, radius: 16, child: Icon(icon, color: Colors.white, size: 18)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildTypingIndicator() {
|
Widget _buildTypingIndicator() {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
|
padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
_buildAvatar(Icons.auto_awesome),
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(right: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||||
decoration: const BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
gradient: LinearGradient(
|
|
||||||
colors: [Color(0xFF8ad5c9), Color(0xFF57a7ed)], // Mint & Blue
|
|
||||||
begin: Alignment.topLeft,
|
|
||||||
end: Alignment.bottomRight,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const CircleAvatar(
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
radius: 16,
|
|
||||||
child: Icon(Icons.auto_awesome, color: Colors.white, size: 18),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 16.0,
|
|
||||||
vertical: 12.0,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(
|
color: const Color(0xFFF1F5F9),
|
||||||
0xFFF1F5F9,
|
borderRadius: const BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20), bottomLeft: Radius.circular(4), bottomRight: Radius.circular(20)),
|
||||||
), // Typing bubble matching assistant light bubble
|
|
||||||
borderRadius: const BorderRadius.only(
|
|
||||||
topLeft: Radius.circular(20),
|
|
||||||
topRight: Radius.circular(20),
|
|
||||||
bottomLeft: Radius.circular(4),
|
|
||||||
bottomRight: Radius.circular(20),
|
|
||||||
),
|
|
||||||
border: Border.all(color: Colors.black.withOpacity(0.05)),
|
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [_buildAnimatedDot(0), const SizedBox(width: 4), _buildAnimatedDot(1), const SizedBox(width: 4), _buildAnimatedDot(2)],
|
||||||
_buildDot(0),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
_buildDot(1),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
_buildDot(2),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -258,21 +192,15 @@ class _ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDot(int index) {
|
Widget _buildAnimatedDot(int index) {
|
||||||
return TweenAnimationBuilder(
|
return AnimatedBuilder(
|
||||||
tween: Tween<double>(begin: 0, end: 1),
|
animation: _typingController,
|
||||||
duration: const Duration(milliseconds: 600),
|
builder: (context, child) {
|
||||||
builder: (context, double value, child) {
|
double value = (_typingController.value + (index * 0.15)) % 1.0;
|
||||||
|
double intensity = 1.0 - (value - 0.5).abs() * 2;
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: (value + (index * 0.3)) % 1.0,
|
opacity: 0.3 + (0.7 * intensity),
|
||||||
child: Container(
|
child: Transform.translate(offset: Offset(0, -3 * intensity), child: Container(width: 6, height: 6, decoration: const BoxDecoration(color: Colors.black54, shape: BoxShape.circle))),
|
||||||
width: 6,
|
|
||||||
height: 6,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.black54,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -285,78 +213,51 @@ class _ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(0.8), // Light backdrop
|
color: Colors.white.withOpacity(0.8),
|
||||||
border: Border(
|
border: Border(top: BorderSide(color: Colors.black.withOpacity(0.05), width: 0.5)),
|
||||||
top: BorderSide(
|
|
||||||
color: Colors.black.withOpacity(0.05),
|
|
||||||
width: 0.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
// BOTÃO APAGAR CHAT
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.delete_sweep_rounded, color: Colors.redAccent),
|
||||||
|
onPressed: _isTyping ? null : _clearChat, // Desativa enquanto digita
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: const Color(
|
color: const Color(0xFFF1F5F9),
|
||||||
0xFFF1F5F9,
|
|
||||||
), // Light input box background
|
|
||||||
borderRadius: BorderRadius.circular(30.0),
|
borderRadius: BorderRadius.circular(30.0),
|
||||||
border: Border.all(color: Colors.black.withOpacity(0.05)),
|
border: Border.all(color: Colors.black.withOpacity(0.05)),
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.2),
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, 2),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _textController,
|
controller: _textController,
|
||||||
|
enabled: !_isTyping, // Bloqueia o campo de texto
|
||||||
onSubmitted: _handleSubmitted,
|
onSubmitted: _handleSubmitted,
|
||||||
style: const TextStyle(color: Colors.black87),
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: "Message EPVChat!...",
|
hintText: _isTyping ? "Aguarde a resposta..." : "Mensagem EPVChat...",
|
||||||
hintStyle: TextStyle(
|
|
||||||
color: Colors.black.withOpacity(0.4),
|
|
||||||
),
|
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
contentPadding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 14.0),
|
||||||
horizontal: 24.0,
|
|
||||||
vertical: 14.0,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 8),
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: const LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [
|
colors: _isTyping
|
||||||
Color(0xFF8ad5c9),
|
? [Colors.grey, Colors.grey] // Cor de desativado
|
||||||
Color(0xFF57a7ed),
|
: [const Color(0xFF8ad5c9), const Color(0xFF57a7ed)],
|
||||||
], // Mint & Blue send button
|
|
||||||
begin: Alignment.topLeft,
|
begin: Alignment.topLeft,
|
||||||
end: Alignment.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
),
|
),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: const Color(0xFF8ad5c9).withOpacity(0.4),
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, 4),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(Icons.send_rounded, color: Colors.white),
|
||||||
Icons.send_rounded,
|
onPressed: _isTyping ? null : () => _handleSubmitted(_textController.text),
|
||||||
color: Colors.white,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
onPressed: () => _handleSubmitted(_textController.text),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -369,83 +270,56 @@ class _ChatScreenState extends State<ChatScreen> with TickerProviderStateMixin {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
backgroundColor: Colors.white,
|
||||||
appBar: PreferredSize(
|
body: Column(
|
||||||
preferredSize: const Size.fromHeight(kToolbarHeight),
|
children: [
|
||||||
child: ClipRRect(
|
Expanded(
|
||||||
child: BackdropFilter(
|
child: ListView(
|
||||||
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
|
controller: _scrollController,
|
||||||
child: AppBar(
|
reverse: true, // Mantém a lógica de mensagens novas em baixo
|
||||||
title: ShaderMask(
|
children: [
|
||||||
shaderCallback: (bounds) => const LinearGradient(
|
// As mensagens vêm primeiro (no reverse: true, o topo da lista é o fundo do ecrã)
|
||||||
colors: [
|
...(_isTyping ? [_buildTypingIndicator()] : []),
|
||||||
Color(0xFF8ad5c9),
|
..._messages.map((msg) => _buildMessage(msg)),
|
||||||
Color(0xFF57a7ed),
|
|
||||||
], // Text gradient header
|
// O LOGO E O SOMBREADO AGORA SÃO O ÚLTIMO ITEM DO LISTVIEW
|
||||||
begin: Alignment.topLeft,
|
// Quando o utilizador sobe o chat, eles sobem junto
|
||||||
end: Alignment.bottomRight,
|
Padding(
|
||||||
).createShader(bounds),
|
padding: const EdgeInsets.only(bottom: 50, top: 20),
|
||||||
child: const Text(
|
child: Stack(
|
||||||
'EPVChat!',
|
alignment: Alignment.center,
|
||||||
style: TextStyle(
|
children: [
|
||||||
fontWeight: FontWeight.w800,
|
// O Sombreado Verde
|
||||||
fontSize: 22,
|
Container(
|
||||||
letterSpacing: -0.5,
|
height: screenWidth * 0.8,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
gradient: RadialGradient(
|
||||||
|
colors: [
|
||||||
|
const Color(0xFF8ad5c9).withOpacity(0.4),
|
||||||
|
const Color(0xFF8ad5c9).withOpacity(0.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// O Logo
|
||||||
|
Image.asset(
|
||||||
|
'assets/logo.png',
|
||||||
|
height: 170,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
backgroundColor: Colors.white.withOpacity(
|
|
||||||
0.7,
|
|
||||||
), // Light Header backgrop
|
|
||||||
elevation: 0,
|
|
||||||
centerTitle: true,
|
|
||||||
bottom: PreferredSize(
|
|
||||||
preferredSize: const Size.fromHeight(1.0),
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black.withOpacity(0.05),
|
|
||||||
height: 1.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
_buildTextComposer(),
|
||||||
),
|
],
|
||||||
body: Container(
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
gradient: RadialGradient(
|
|
||||||
center: Alignment.topCenter,
|
|
||||||
radius: 1.5,
|
|
||||||
colors: [
|
|
||||||
Colors.white,
|
|
||||||
Color(0xFFF8FAFC), // Slate 50
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: SafeArea(
|
|
||||||
bottom: false,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: ListView.builder(
|
|
||||||
controller: _scrollController,
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
|
||||||
reverse: true,
|
|
||||||
itemCount: _messages.length + (_isTyping ? 1 : 0),
|
|
||||||
itemBuilder: (_, int index) {
|
|
||||||
if (_isTyping && index == 0) {
|
|
||||||
return _buildTypingIndicator();
|
|
||||||
}
|
|
||||||
int messageIndex = _isTyping ? index - 1 : index;
|
|
||||||
return _buildMessage(_messages[messageIndex]);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
_buildTextComposer(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
72
pubspec.yaml
72
pubspec.yaml
@@ -1,90 +1,24 @@
|
|||||||
name: app
|
name: app
|
||||||
description: "A new Flutter project."
|
description: "A new Flutter project."
|
||||||
# The following line prevents the package from being accidentally published to
|
publish_to: 'none'
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|
||||||
|
|
||||||
# The following defines the version and build number for your application.
|
|
||||||
# A version number is three numbers separated by dots, like 1.2.43
|
|
||||||
# followed by an optional build number separated by a +.
|
|
||||||
# Both the version and the builder number may be overridden in flutter
|
|
||||||
# build by specifying --build-name and --build-number, respectively.
|
|
||||||
# In Android, build-name is used as versionName while build-number used as versionCode.
|
|
||||||
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
|
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
|
|
||||||
# Read more about iOS versioning at
|
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
|
||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.11.1
|
sdk: ^3.11.1
|
||||||
|
|
||||||
# Dependencies specify other packages that your package needs in order to work.
|
|
||||||
# To automatically upgrade your package dependencies to the latest versions
|
|
||||||
# consider running `flutter pub upgrade --major-versions`. Alternatively,
|
|
||||||
# dependencies can be manually updated by changing the version numbers below to
|
|
||||||
# the latest version available on pub.dev. To see which dependencies have newer
|
|
||||||
# versions available, run `flutter pub outdated`.
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
http: ^1.6.0
|
http: ^1.6.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
# The "flutter_lints" package below contains a set of recommended lints to
|
|
||||||
# encourage good coding practices. The lint set provided by the package is
|
|
||||||
# activated in the `analysis_options.yaml` file located at the root of your
|
|
||||||
# package. See that file for information about deactivating specific lint
|
|
||||||
# rules and activating additional ones.
|
|
||||||
flutter_lints: ^6.0.0
|
flutter_lints: ^6.0.0
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
|
||||||
# following page: https://dart.dev/tools/pub/pubspec
|
|
||||||
|
|
||||||
# The following section is specific to Flutter packages.
|
|
||||||
flutter:
|
flutter:
|
||||||
|
|
||||||
# The following line ensures that the Material Icons font is
|
|
||||||
# included with your application, so that you can use the icons in
|
|
||||||
# the material Icons class.
|
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
assets:
|
||||||
# To add assets to your application, add an assets section, like this:
|
- assets/logo.png
|
||||||
# assets:
|
|
||||||
# - images/a_dot_burr.jpeg
|
|
||||||
# - images/a_dot_ham.jpeg
|
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
|
||||||
# https://flutter.dev/to/resolution-aware-images
|
|
||||||
|
|
||||||
# For details regarding adding assets from package dependencies, see
|
|
||||||
# https://flutter.dev/to/asset-from-package
|
|
||||||
|
|
||||||
# To add custom fonts to your application, add a fonts section here,
|
|
||||||
# in this "flutter" section. Each entry in this list should have a
|
|
||||||
# "family" key with the font family name, and a "fonts" key with a
|
|
||||||
# list giving the asset and other descriptors for the font. For
|
|
||||||
# example:
|
|
||||||
# fonts:
|
|
||||||
# - family: Schyler
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/Schyler-Regular.ttf
|
|
||||||
# - asset: fonts/Schyler-Italic.ttf
|
|
||||||
# style: italic
|
|
||||||
# - family: Trajan Pro
|
|
||||||
# fonts:
|
|
||||||
# - asset: fonts/TrajanPro.ttf
|
|
||||||
# - asset: fonts/TrajanPro_Bold.ttf
|
|
||||||
# weight: 700
|
|
||||||
#
|
|
||||||
# For details regarding fonts from package dependencies,
|
|
||||||
# see https://flutter.dev/to/font-from-package
|
|
||||||
|
|||||||
Reference in New Issue
Block a user