Merge pull request #208 from pangeachat/196-ui-to-allow-changing-different-bot-modes
196 UI to allow changing different bot modes
This commit is contained in:
commit
075f7deb13
13 changed files with 1422 additions and 56 deletions
|
|
@ -3945,6 +3945,21 @@
|
|||
"accuracy": "Accuracy",
|
||||
"points": "Points",
|
||||
"noPaymentInfo": "No payment info necessary!",
|
||||
"conversationBotModeSelectDescription": "Bot mode",
|
||||
"conversationBotModeSelectOption_discussion": "Discussion",
|
||||
"conversationBotModeSelectOption_custom": "Custom",
|
||||
"conversationBotModeSelectOption_conversation": "Conversation",
|
||||
"conversationBotModeSelectOption_textAdventure": "Text Adventure",
|
||||
"conversationBotDiscussionZone_title": "Discussion Settings",
|
||||
"conversationBotDiscussionZone_discussionTopicLabel": "Discussion Topic",
|
||||
"conversationBotDiscussionZone_discussionTopicPlaceholder": "Set Discussion Topic",
|
||||
"conversationBotDiscussionZone_discussionKeywordsLabel": "Discussion Keywords",
|
||||
"conversationBotDiscussionZone_discussionKeywordsPlaceholder": "Set Discussion Keywords",
|
||||
"conversationBotDiscussionZone_discussionKeywordsHintText": "Comma separated list of keywords to guide the discussion",
|
||||
"conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel": "Send discussion prompt on a schedule",
|
||||
"conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel": "Hours between discussion prompts",
|
||||
"conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel": "Send discussion prompt when user reacts ⏩ to bot message",
|
||||
"conversationBotDiscussionZone_discussionTriggerReactionKeyLabel": "Reaction to send discussion prompt",
|
||||
"studentAnalyticsNotAvailable": "Student data not currently available",
|
||||
"roomDataMissing": "Some data may be missing from rooms in which you are not a member.",
|
||||
"updatePhoneOS": "You may need to update your device's OS version.",
|
||||
|
|
|
|||
|
|
@ -96,7 +96,17 @@ class ModelKey {
|
|||
|
||||
// bot options
|
||||
static const String languageLevel = "difficulty";
|
||||
static const String conversationTopic = "conversation_topic";
|
||||
static const String keywords = "keywords";
|
||||
static const String safetyModeration = "safety_moderation";
|
||||
static const String mode = "mode";
|
||||
static const String custom = "custom";
|
||||
static const String discussionTopic = "discussion_topic";
|
||||
static const String discussionKeywords = "discussion_keywords";
|
||||
static const String discussionTriggerScheduleEnabled =
|
||||
"discussion_trigger_schedule_enabled";
|
||||
static const String discussionTriggerScheduleHourInterval =
|
||||
"discussion_trigger_schedule_hour_interval";
|
||||
static const String discussionTriggerReactionEnabled =
|
||||
"discussion_trigger_reaction_enabled";
|
||||
static const String discussionTriggerReactionKey =
|
||||
"discussion_trigger_reaction_key";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,20 +12,45 @@ class BotOptionsModel {
|
|||
String topic;
|
||||
List<String> keywords;
|
||||
bool safetyModeration;
|
||||
String mode;
|
||||
String? custom;
|
||||
String? discussionTopic;
|
||||
String? discussionKeywords;
|
||||
bool? discussionTriggerScheduleEnabled;
|
||||
int? discussionTriggerScheduleHourInterval;
|
||||
bool? discussionTriggerReactionEnabled;
|
||||
String? discussionTriggerReactionKey;
|
||||
|
||||
BotOptionsModel({
|
||||
this.languageLevel,
|
||||
this.topic = "General Conversation",
|
||||
this.keywords = const [],
|
||||
this.safetyModeration = true,
|
||||
this.mode = "discussion",
|
||||
this.custom = "",
|
||||
this.discussionTopic,
|
||||
this.discussionKeywords,
|
||||
this.discussionTriggerScheduleEnabled,
|
||||
this.discussionTriggerScheduleHourInterval,
|
||||
this.discussionTriggerReactionEnabled,
|
||||
this.discussionTriggerReactionKey,
|
||||
});
|
||||
|
||||
factory BotOptionsModel.fromJson(json) {
|
||||
return BotOptionsModel(
|
||||
languageLevel: json[ModelKey.languageLevel],
|
||||
topic: json[ModelKey.conversationTopic] ?? "General Conversation",
|
||||
keywords: (json[ModelKey.keywords] ?? []).cast<String>(),
|
||||
safetyModeration: json[ModelKey.safetyModeration] ?? true,
|
||||
mode: json[ModelKey.mode] ?? "discussion",
|
||||
custom: json[ModelKey.custom],
|
||||
discussionTopic: json[ModelKey.discussionTopic],
|
||||
discussionKeywords: json[ModelKey.discussionKeywords],
|
||||
discussionTriggerScheduleEnabled:
|
||||
json[ModelKey.discussionTriggerScheduleEnabled],
|
||||
discussionTriggerScheduleHourInterval:
|
||||
json[ModelKey.discussionTriggerScheduleHourInterval],
|
||||
discussionTriggerReactionEnabled:
|
||||
json[ModelKey.discussionTriggerReactionEnabled],
|
||||
discussionTriggerReactionKey: json[ModelKey.discussionTriggerReactionKey],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -34,9 +59,19 @@ class BotOptionsModel {
|
|||
try {
|
||||
// data[ModelKey.isConversationBotChat] = isConversationBotChat;
|
||||
data[ModelKey.languageLevel] = languageLevel;
|
||||
data[ModelKey.conversationTopic] = topic;
|
||||
data[ModelKey.keywords] = keywords;
|
||||
data[ModelKey.safetyModeration] = safetyModeration;
|
||||
data[ModelKey.mode] = mode;
|
||||
data[ModelKey.custom] = custom;
|
||||
data[ModelKey.discussionTopic] = discussionTopic;
|
||||
data[ModelKey.discussionKeywords] = discussionKeywords;
|
||||
data[ModelKey.discussionTriggerScheduleEnabled] =
|
||||
discussionTriggerScheduleEnabled;
|
||||
data[ModelKey.discussionTriggerScheduleHourInterval] =
|
||||
discussionTriggerScheduleHourInterval;
|
||||
data[ModelKey.discussionTriggerReactionEnabled] =
|
||||
discussionTriggerReactionEnabled;
|
||||
data[ModelKey.discussionTriggerReactionKey] =
|
||||
discussionTriggerReactionKey;
|
||||
return data;
|
||||
} catch (e, s) {
|
||||
debugger(when: kDebugMode);
|
||||
|
|
@ -51,15 +86,33 @@ class BotOptionsModel {
|
|||
case ModelKey.languageLevel:
|
||||
languageLevel = value;
|
||||
break;
|
||||
case ModelKey.conversationTopic:
|
||||
topic = value;
|
||||
break;
|
||||
case ModelKey.keywords:
|
||||
keywords = value;
|
||||
break;
|
||||
case ModelKey.safetyModeration:
|
||||
safetyModeration = value;
|
||||
break;
|
||||
case ModelKey.mode:
|
||||
mode = value;
|
||||
break;
|
||||
case ModelKey.custom:
|
||||
custom = value;
|
||||
break;
|
||||
case ModelKey.discussionTopic:
|
||||
discussionTopic = value;
|
||||
break;
|
||||
case ModelKey.discussionKeywords:
|
||||
discussionKeywords = value;
|
||||
break;
|
||||
case ModelKey.discussionTriggerScheduleEnabled:
|
||||
discussionTriggerScheduleEnabled = value;
|
||||
break;
|
||||
case ModelKey.discussionTriggerScheduleHourInterval:
|
||||
discussionTriggerScheduleHourInterval = value;
|
||||
break;
|
||||
case ModelKey.discussionTriggerReactionEnabled:
|
||||
discussionTriggerReactionEnabled = value;
|
||||
break;
|
||||
case ModelKey.discussionTriggerReactionKey:
|
||||
discussionTriggerReactionKey = value;
|
||||
break;
|
||||
default:
|
||||
throw Exception('Invalid key for bot options - $key');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ConversationBotConversationZone extends StatelessWidget {
|
||||
const ConversationBotConversationZone({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Column(
|
||||
children: [
|
||||
Text('Conversation Zone'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ConversationBotCustomZone extends StatelessWidget {
|
||||
const ConversationBotCustomZone({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Column(
|
||||
children: [
|
||||
Text('Custom Zone'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class ConversationBotDiscussionKeywordsInput extends StatelessWidget {
|
||||
final BotOptionsModel initialBotOptions;
|
||||
// call this to update propagate changes to parents
|
||||
final void Function(BotOptionsModel) onChanged;
|
||||
|
||||
const ConversationBotDiscussionKeywordsInput({
|
||||
super.key,
|
||||
required this.initialBotOptions,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String discussionKeywords = initialBotOptions.discussionKeywords ?? "";
|
||||
|
||||
final TextEditingController textFieldController =
|
||||
TextEditingController(text: discussionKeywords);
|
||||
|
||||
void setBotDiscussionKeywordsAction() async {
|
||||
showDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: Text(
|
||||
L10n.of(context)!
|
||||
.conversationBotDiscussionZone_discussionKeywordsLabel,
|
||||
),
|
||||
content: TextField(
|
||||
controller: textFieldController,
|
||||
onChanged: (value) {
|
||||
discussionKeywords = value;
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(L10n.of(context)!.cancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(L10n.of(context)!.ok),
|
||||
onPressed: () {
|
||||
if (discussionKeywords == "") return;
|
||||
if (discussionKeywords !=
|
||||
initialBotOptions.discussionKeywords) {
|
||||
initialBotOptions.discussionKeywords = discussionKeywords;
|
||||
onChanged.call(initialBotOptions);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
onTap: setBotDiscussionKeywordsAction,
|
||||
title: Text(
|
||||
initialBotOptions.discussionKeywords ??
|
||||
L10n.of(context)!
|
||||
.conversationBotDiscussionZone_discussionKeywordsPlaceholder,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class ConversationBotDiscussionTopicInput extends StatelessWidget {
|
||||
final BotOptionsModel initialBotOptions;
|
||||
// call this to update propagate changes to parents
|
||||
final void Function(BotOptionsModel) onChanged;
|
||||
|
||||
const ConversationBotDiscussionTopicInput({
|
||||
super.key,
|
||||
required this.initialBotOptions,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String discussionTopic = initialBotOptions.discussionTopic ?? "";
|
||||
|
||||
final TextEditingController textFieldController =
|
||||
TextEditingController(text: discussionTopic);
|
||||
|
||||
void setBotDiscussionTopicAction() async {
|
||||
showDialog(
|
||||
context: context,
|
||||
useRootNavigator: false,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
title: Text(
|
||||
L10n.of(context)!
|
||||
.conversationBotDiscussionZone_discussionTopicLabel,
|
||||
),
|
||||
content: TextField(
|
||||
controller: textFieldController,
|
||||
onChanged: (value) {
|
||||
discussionTopic = value;
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text(L10n.of(context)!.cancel),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text(L10n.of(context)!.ok),
|
||||
onPressed: () {
|
||||
if (discussionTopic == "") return;
|
||||
if (discussionTopic != initialBotOptions.discussionTopic) {
|
||||
initialBotOptions.discussionTopic = discussionTopic;
|
||||
onChanged.call(initialBotOptions);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
onTap: setBotDiscussionTopicAction,
|
||||
title: Text(
|
||||
initialBotOptions.discussionTopic ??
|
||||
L10n.of(context)!
|
||||
.conversationBotDiscussionZone_discussionTopicPlaceholder,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_discussion_keywords_input.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_discussion_topic_input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class ConversationBotDiscussionZone extends StatelessWidget {
|
||||
final BotOptionsModel initialBotOptions;
|
||||
// call this to update propagate changes to parents
|
||||
final void Function(BotOptionsModel) onChanged;
|
||||
|
||||
const ConversationBotDiscussionZone({
|
||||
super.key,
|
||||
required this.initialBotOptions,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String discussionTopic = initialBotOptions.discussionTopic ?? "";
|
||||
final String discussionKeywords =
|
||||
initialBotOptions.discussionKeywords ?? "";
|
||||
// int discussionTriggerScheduleHourInterval =
|
||||
// initialBotOptions.discussionTriggerScheduleHourInterval ?? 24;
|
||||
// String discussionTriggerReactionKey =
|
||||
// initialBotOptions.discussionTriggerReactionKey ?? "⏩";
|
||||
// List<String> reactionKeyOptions = ["⏩"];
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
L10n.of(context)!.conversationBotDiscussionZone_title,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
color: Colors.grey,
|
||||
thickness: 1,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 0, 0),
|
||||
child: Text(
|
||||
L10n.of(context)!
|
||||
.conversationBotDiscussionZone_discussionTopicLabel,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: ConversationBotDiscussionTopicInput(
|
||||
initialBotOptions: initialBotOptions,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(12, 0, 0, 0),
|
||||
child: Text(
|
||||
L10n.of(context)!
|
||||
.conversationBotDiscussionZone_discussionKeywordsLabel,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: ConversationBotDiscussionKeywordsInput(
|
||||
initialBotOptions: initialBotOptions,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// CheckboxListTile(
|
||||
// title: Text(
|
||||
// L10n.of(context)!
|
||||
// .conversationBotDiscussionZone_discussionTriggerScheduleEnabledLabel,
|
||||
// ),
|
||||
// value: initialBotOptions.discussionTriggerScheduleEnabled ?? false,
|
||||
// onChanged: (value) {
|
||||
// initialBotOptions.discussionTriggerScheduleEnabled = value ?? false;
|
||||
// onChanged?.call(initialBotOptions);
|
||||
// },
|
||||
// ),
|
||||
// if (initialBotOptions.discussionTriggerScheduleEnabled == true)
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8),
|
||||
// child: TextField(
|
||||
// keyboardType: TextInputType.number,
|
||||
// controller: TextEditingController(
|
||||
// text: discussionTriggerScheduleHourInterval.toString(),
|
||||
// ),
|
||||
// onChanged: (value) {
|
||||
// discussionTriggerScheduleHourInterval =
|
||||
// int.tryParse(value) ?? 0;
|
||||
// },
|
||||
// decoration: InputDecoration(
|
||||
// labelText: L10n.of(context)!
|
||||
// .conversationBotDiscussionZone_discussionTriggerScheduleHourIntervalLabel,
|
||||
// floatingLabelBehavior: FloatingLabelBehavior.auto,
|
||||
// suffixIcon: IconButton(
|
||||
// icon: const Icon(Icons.check),
|
||||
// onPressed: () {
|
||||
// if (discussionTriggerScheduleHourInterval !=
|
||||
// initialBotOptions
|
||||
// .discussionTriggerScheduleHourInterval) {
|
||||
// initialBotOptions.discussionTriggerScheduleHourInterval =
|
||||
// discussionTriggerScheduleHourInterval;
|
||||
// onChanged?.call(
|
||||
// initialBotOptions,
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 12),
|
||||
CheckboxListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!
|
||||
.conversationBotDiscussionZone_discussionTriggerReactionEnabledLabel,
|
||||
),
|
||||
value: initialBotOptions.discussionTriggerReactionEnabled ?? false,
|
||||
onChanged: (value) {
|
||||
initialBotOptions.discussionTriggerReactionEnabled = value ?? false;
|
||||
initialBotOptions.discussionTriggerReactionKey =
|
||||
"⏩"; // hard code this for now
|
||||
onChanged.call(initialBotOptions);
|
||||
},
|
||||
),
|
||||
// if (initialBotOptions.discussionTriggerReactionEnabled == true)
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Text(
|
||||
// L10n.of(context)!
|
||||
// .conversationBotDiscussionZone_discussionTriggerReactionKeyLabel,
|
||||
// style: TextStyle(
|
||||
// color: Theme.of(context).colorScheme.secondary,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// textAlign: TextAlign.left,
|
||||
// ),
|
||||
// Container(
|
||||
// decoration: BoxDecoration(
|
||||
// border: Border.all(
|
||||
// color: Theme.of(context).colorScheme.secondary,
|
||||
// width: 0.5,
|
||||
// ),
|
||||
// borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
// ),
|
||||
// child: DropdownButton(
|
||||
// // Initial Value
|
||||
// hint: Padding(
|
||||
// padding: const EdgeInsets.only(left: 15),
|
||||
// child: Text(
|
||||
// reactionKeyOptions[0],
|
||||
// style: const TextStyle().copyWith(
|
||||
// color: Theme.of(context).textTheme.bodyLarge!.color,
|
||||
// fontSize: 14,
|
||||
// ),
|
||||
// overflow: TextOverflow.clip,
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// ),
|
||||
// isExpanded: true,
|
||||
// underline: Container(),
|
||||
// // Down Arrow Icon
|
||||
// icon: const Icon(Icons.keyboard_arrow_down),
|
||||
// // Array list of items
|
||||
// items: [
|
||||
// for (final entry in reactionKeyOptions)
|
||||
// DropdownMenuItem(
|
||||
// value: entry,
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(left: 15),
|
||||
// child: Text(
|
||||
// entry,
|
||||
// style: const TextStyle().copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .textTheme
|
||||
// .bodyLarge!
|
||||
// .color,
|
||||
// fontSize: 14,
|
||||
// ),
|
||||
// overflow: TextOverflow.clip,
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// onChanged: (String? value) {
|
||||
// if (value !=
|
||||
// initialBotOptions.discussionTriggerReactionKey) {
|
||||
// initialBotOptions.discussionTriggerReactionKey = value;
|
||||
// onChanged?.call(
|
||||
// initialBotOptions,
|
||||
// );
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_conversation_zone.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'conversation_bot_discussion_zone.dart';
|
||||
|
||||
class ConversationBotModeDynamicZone extends StatelessWidget {
|
||||
final BotOptionsModel initialBotOptions;
|
||||
final void Function(BotOptionsModel) onChanged;
|
||||
|
||||
const ConversationBotModeDynamicZone({
|
||||
super.key,
|
||||
required this.initialBotOptions,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final zoneMap = {
|
||||
'discussion': ConversationBotDiscussionZone(
|
||||
initialBotOptions: initialBotOptions,
|
||||
onChanged: onChanged,
|
||||
),
|
||||
"custom": const ConversationBotCustomZone(),
|
||||
"conversation": const ConversationBotConversationZone(),
|
||||
"text_adventure": const ConversationBotTextAdventureZone(),
|
||||
};
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
width: 0.5,
|
||||
),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: zoneMap[initialBotOptions.mode],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
|
||||
class ConversationBotModeSelect extends StatelessWidget {
|
||||
final String? initialMode;
|
||||
final void Function(String?)? onChanged;
|
||||
|
||||
const ConversationBotModeSelect({
|
||||
super.key,
|
||||
this.initialMode,
|
||||
this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Map<String, String> options = {
|
||||
"discussion":
|
||||
L10n.of(context)!.conversationBotModeSelectOption_discussion,
|
||||
// "custom": L10n.of(context)!.conversationBotModeSelectOption_custom,
|
||||
// "conversation":
|
||||
// L10n.of(context)!.conversationBotModeSelectOption_conversation,
|
||||
// "text_adventure":
|
||||
// L10n.of(context)!.conversationBotModeSelectOption_textAdventure,
|
||||
};
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
width: 0.5,
|
||||
),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: DropdownButton(
|
||||
// Initial Value
|
||||
hint: Padding(
|
||||
padding: const EdgeInsets.only(left: 15),
|
||||
child: Text(
|
||||
options[initialMode ?? "discussion"]!,
|
||||
style: const TextStyle().copyWith(
|
||||
color: Theme.of(context).textTheme.bodyLarge!.color,
|
||||
fontSize: 14,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
isExpanded: true,
|
||||
underline: Container(),
|
||||
// Down Arrow Icon
|
||||
icon: const Icon(Icons.keyboard_arrow_down),
|
||||
// Array list of items
|
||||
items: [
|
||||
for (final entry in options.entries)
|
||||
DropdownMenuItem(
|
||||
value: entry.key,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 15),
|
||||
child: Text(
|
||||
entry.value,
|
||||
style: const TextStyle().copyWith(
|
||||
color: Theme.of(context).textTheme.bodyLarge!.color,
|
||||
fontSize: 14,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
onChanged: onChanged,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/models/bot_options_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/widgets/common/bot_face_svg.dart';
|
||||
import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_mode_dynamic_zone.dart';
|
||||
import 'package:fluffychat/pangea/widgets/space/language_level_dropdown.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -156,49 +156,49 @@ class ConversationBotSettingsState extends State<ConversationBotSettings> {
|
|||
),
|
||||
),
|
||||
if (addBot) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: ListTile(
|
||||
onTap: () async {
|
||||
final topic = await showTextInputDialog(
|
||||
context: context,
|
||||
textFields: [
|
||||
DialogTextField(
|
||||
initialText: botOptions.topic.isEmpty
|
||||
? ""
|
||||
: botOptions.topic,
|
||||
hintText:
|
||||
L10n.of(context)!.enterAConversationTopic,
|
||||
),
|
||||
],
|
||||
title: L10n.of(context)!.conversationTopic,
|
||||
);
|
||||
if (topic == null) return;
|
||||
updateBotOption(() {
|
||||
botOptions.topic = topic.single;
|
||||
});
|
||||
},
|
||||
leading: CircleAvatar(
|
||||
backgroundColor:
|
||||
Theme.of(context).scaffoldBackgroundColor,
|
||||
foregroundColor:
|
||||
Theme.of(context).textTheme.bodyLarge!.color,
|
||||
child: const Icon(Icons.topic_outlined),
|
||||
),
|
||||
subtitle: Text(
|
||||
botOptions.topic.isEmpty
|
||||
? L10n.of(context)!.enterAConversationTopic
|
||||
: botOptions.topic,
|
||||
),
|
||||
title: Text(
|
||||
L10n.of(context)!.conversationTopic,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 16),
|
||||
// child: ListTile(
|
||||
// onTap: () async {
|
||||
// final topic = await showTextInputDialog(
|
||||
// context: context,
|
||||
// textFields: [
|
||||
// DialogTextField(
|
||||
// initialText: botOptions.topic.isEmpty
|
||||
// ? ""
|
||||
// : botOptions.topic,
|
||||
// hintText:
|
||||
// L10n.of(context)!.enterAConversationTopic,
|
||||
// ),
|
||||
// ],
|
||||
// title: L10n.of(context)!.conversationTopic,
|
||||
// );
|
||||
// if (topic == null) return;
|
||||
// updateBotOption(() {
|
||||
// botOptions.topic = topic.single;
|
||||
// });
|
||||
// },
|
||||
// leading: CircleAvatar(
|
||||
// backgroundColor:
|
||||
// Theme.of(context).scaffoldBackgroundColor,
|
||||
// foregroundColor:
|
||||
// Theme.of(context).textTheme.bodyLarge!.color,
|
||||
// child: const Icon(Icons.topic_outlined),
|
||||
// ),
|
||||
// subtitle: Text(
|
||||
// botOptions.topic.isEmpty
|
||||
// ? L10n.of(context)!.enterAConversationTopic
|
||||
// : botOptions.topic,
|
||||
// ),
|
||||
// title: Text(
|
||||
// L10n.of(context)!.conversationTopic,
|
||||
// style: TextStyle(
|
||||
// color: Theme.of(context).colorScheme.secondary,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 16),
|
||||
// child: SwitchListTile.adaptive(
|
||||
|
|
@ -244,6 +244,41 @@ class ConversationBotSettingsState extends State<ConversationBotSettings> {
|
|||
}),
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.fromLTRB(32, 16, 0, 0),
|
||||
// child: Text(
|
||||
// L10n.of(context)!.conversationBotModeSelectDescription,
|
||||
// style: TextStyle(
|
||||
// color: Theme.of(context).colorScheme.secondary,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// fontSize: 16,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.only(left: 16),
|
||||
// child: ConversationBotModeSelect(
|
||||
// initialMode: botOptions.mode,
|
||||
// onChanged: (String? mode) => updateBotOption(
|
||||
// () {
|
||||
// botOptions.mode = mode ?? "discussion";
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(28, 0, 12, 0),
|
||||
child: ConversationBotModeDynamicZone(
|
||||
initialBotOptions: botOptions,
|
||||
onChanged: (BotOptionsModel? newOptions) {
|
||||
updateBotOption(() {
|
||||
if (newOptions != null) {
|
||||
botOptions = newOptions;
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ConversationBotTextAdventureZone extends StatelessWidget {
|
||||
const ConversationBotTextAdventureZone({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Column(
|
||||
children: [
|
||||
Text('Text Adventure Zone'),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue