implemented basic settings into the backend, renamed files, fixed bugs, and added back button functionality
This commit is contained in:
@@ -5,6 +5,7 @@ import '/components/conversation_thread/conversation_thread_widget.dart';
|
||||
import '/components/model_item/model_item_widget.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:app/theme.dart';
|
||||
|
||||
@@ -64,17 +65,9 @@ class _ConversationWidgetState extends State<ConversationWidget> {
|
||||
),
|
||||
onPressed: () async {
|
||||
print("something pressed in conversation_widget.dart");
|
||||
// TODO
|
||||
// context.goNamed(
|
||||
// 'ConversationsList',
|
||||
// extra: <String, dynamic>{
|
||||
// kTransitionInfoKey: TransitionInfo(
|
||||
// hasTransition: true,
|
||||
// transitionType: PageTransitionType.leftToRight,
|
||||
// duration: const Duration(milliseconds: 250),
|
||||
// ),
|
||||
// },
|
||||
// );
|
||||
// TODO: Smooth out the animation to prevent the conversations list from loading half-way up the screen.
|
||||
SystemChannels.textInput.invokeMethod('TextInput.hide');
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
title: wrapWithModel(
|
||||
|
||||
@@ -2,11 +2,12 @@ import 'package:app/components/conversation_thread/conversation.dart';
|
||||
import 'package:app/theme.dart';
|
||||
|
||||
import 'package:app/pages/conversation_widget.dart';
|
||||
import 'package:app/util/server.dart';
|
||||
import 'package:app/util/backend.dart';
|
||||
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:app/components/options_dialog/options_dialog_widget.dart';
|
||||
import 'conversations_list_model.dart';
|
||||
export 'conversations_list_model.dart';
|
||||
|
||||
@@ -48,6 +49,20 @@ class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Clean conversation list prior to building widgets, to prevent bloating UI with empty conversations.
|
||||
// Additionally, delete conversations that have history disabled.
|
||||
for(int i = 0; i < conversations.length; i++) {
|
||||
if(
|
||||
conversations[i].conversation.getChats().isEmpty ||
|
||||
!conversations[i].conversation.history
|
||||
) {
|
||||
Backend.conversations.removeAt(i);
|
||||
conversations.removeAt(i);
|
||||
Backend.maxConversationID--; // maxConversationID will eventually be deprecated with better ID system.
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => _model.unfocusNode.canRequestFocus
|
||||
? FocusScope.of(context).requestFocus(_model.unfocusNode)
|
||||
@@ -181,6 +196,24 @@ class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
)
|
||||
},
|
||||
onLongPress: () => {
|
||||
showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor:
|
||||
Colors.transparent,
|
||||
enableDrag: false,
|
||||
useSafeArea: true,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return Padding(
|
||||
padding:
|
||||
MediaQuery.viewInsetsOf(
|
||||
context),
|
||||
child: const PopupWidget(),
|
||||
);
|
||||
},
|
||||
).then((value) =>
|
||||
safeSetState(() {})),
|
||||
|
||||
// TODO: Need to implement.
|
||||
print("opening options")
|
||||
},
|
||||
@@ -197,7 +230,7 @@ class _ConversationsListWidgetState extends State<ConversationsListWidget> {
|
||||
right: 20.0, // Adjust positioning as needed
|
||||
child: FloatingActionButton(
|
||||
onPressed: () => {
|
||||
Backend.loadConversation(Backend.maxConversationID), // TODO: Dynamically get the next ID
|
||||
Backend.loadConversation(Backend.createConversation()), // TODO: Dynamically get the next ID
|
||||
conversations.add(ConversationWidget(conversation: Backend.getLoadedConversation())),
|
||||
Navigator.push(
|
||||
context,
|
||||
|
||||
@@ -1169,6 +1169,7 @@ class _SettingsWidgetState extends State<SettingsWidget>
|
||||
focusColor: Colors.transparent,
|
||||
hoverColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
// TODO: Should open in a browser rather than in-app?
|
||||
onTap: () async {
|
||||
await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
|
||||
Reference in New Issue
Block a user