fixed bugs relating to ui and duplicating conversations.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'package:app/components/conversation_thread/conversation.dart';
|
||||
|
||||
import '/components/conversation_thread/conversation_thread_widget.dart';
|
||||
import '/components/model_item/model_item_widget.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
@@ -13,9 +15,13 @@ class ConversationModel extends FlutterFlowModel<ConversationWidget> {
|
||||
// Model for ModelItem component.
|
||||
late ModelItemModel modelItemModel;
|
||||
|
||||
late Conversation conversation;
|
||||
|
||||
ConversationModel(this.conversation);
|
||||
|
||||
@override
|
||||
void initState(BuildContext context) {
|
||||
conversationThreadModel = createModel(context, () => ConversationThreadModel()); // TODO
|
||||
conversationThreadModel = createModel(context, () => ConversationThreadModel(conversation)); // TODO
|
||||
modelItemModel = createModel(context, () => ModelItemModel());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:app/components/conversation_thread/conversation.dart';
|
||||
|
||||
import '/components/conversation_details_overlay/conversation_details_overlay_widget.dart';
|
||||
import '/components/conversation_thread/conversation_thread_widget.dart';
|
||||
import '/components/model_item/model_item_widget.dart';
|
||||
@@ -10,22 +12,24 @@ import 'conversation_model.dart';
|
||||
export 'conversation_model.dart';
|
||||
|
||||
class ConversationWidget extends StatefulWidget {
|
||||
const ConversationWidget({super.key});
|
||||
final Conversation conversation;
|
||||
const ConversationWidget({super.key, required this.conversation});
|
||||
|
||||
@override
|
||||
State<ConversationWidget> createState() => _ConversationWidgetState();
|
||||
State<ConversationWidget> createState() => _ConversationWidgetState(conversation);
|
||||
}
|
||||
|
||||
class _ConversationWidgetState extends State<ConversationWidget> {
|
||||
late ConversationModel _model;
|
||||
Conversation conversation;
|
||||
|
||||
_ConversationWidgetState();
|
||||
_ConversationWidgetState(this.conversation);
|
||||
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_model = createModel(context, () => ConversationModel());
|
||||
_model = createModel(context, () => ConversationModel(conversation));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -124,7 +128,7 @@ class _ConversationWidgetState extends State<ConversationWidget> {
|
||||
child: wrapWithModel(
|
||||
model: _model.conversationThreadModel,
|
||||
updateCallback: () => setState(() {}),
|
||||
child: const ConversationThreadWidget(),
|
||||
child: ConversationThreadWidget(conversation: conversation),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:app/components/conversation_thread/conversation.dart';
|
||||
import 'package:app/theme.dart';
|
||||
|
||||
import 'package:app/pages/conversation_widget.dart';
|
||||
import 'package:app/components/conversation_options/conversation_options_widget.dart';
|
||||
import 'package:app/util/server.dart';
|
||||
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
@@ -22,14 +21,8 @@ class ConversationsListWidget extends StatefulWidget {
|
||||
|
||||
class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
late ConversationsListModel _model;
|
||||
final selectedIndexProvider = StateProvider<int>((_) => 0); // Initial state
|
||||
|
||||
late List<Widget> conversations = [];
|
||||
// = [
|
||||
// // TODO: Dynamically generate list of pages based upon existing conversations.
|
||||
// // This requires retrievable conversations from the server side.
|
||||
// const Center(child: ConversationWidget()),
|
||||
// ];
|
||||
static List<ConversationWidget> conversations = [];
|
||||
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
@@ -37,9 +30,12 @@ class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
Server().init();
|
||||
List<Conversation> convos = Server.conversations;
|
||||
for(Conversation c in convos) {
|
||||
conversations.add(const ConversationWidget());
|
||||
|
||||
if(conversations.isEmpty) {
|
||||
List<Conversation> convoys = Server.conversations;
|
||||
for(Conversation c in convoys) {
|
||||
conversations.add(ConversationWidget(conversation: c,));
|
||||
}
|
||||
}
|
||||
|
||||
_model = createModel(context, () => ConversationsListModel());
|
||||
@@ -53,7 +49,6 @@ class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Conversation> conversations = Server.getConversationsList();
|
||||
return GestureDetector(
|
||||
onTap: () => _model.unfocusNode.canRequestFocus
|
||||
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
||||
@@ -133,7 +128,7 @@ class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
conversations[index].conversationLabel,
|
||||
conversations[index].conversation.conversationLabel,
|
||||
style: AppTheme.headlineLarge,
|
||||
),
|
||||
],
|
||||
@@ -147,7 +142,7 @@ class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
conversations[index].conversationSubLabel,
|
||||
conversations[index].conversation.conversationSubLabel,
|
||||
style: AppTheme.bodyMedium,
|
||||
),
|
||||
),
|
||||
@@ -181,7 +176,7 @@ class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ConversationWidget(),
|
||||
builder: (context) => ConversationWidget(conversation: Server.getLoadedConversation(),),
|
||||
),
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user