From c193c928a1b8ff4169e61ae02af1629f7b5084eb Mon Sep 17 00:00:00 2001 From: WilsonLe Date: Wed, 7 Aug 2024 11:27:22 -0400 Subject: [PATCH] implement dynamic zone label and title shared component --- .../conversation_bot_custom_zone.dart | 32 +++---------- .../conversation_bot_discussion_zone.dart | 48 ++++--------------- .../conversation_bot_dynamic_zone_label.dart | 27 +++++++++++ .../conversation_bot_dynamic_zone_title.dart | 31 ++++++++++++ .../conversation_bot_text_adventure_zone.dart | 32 +++---------- 5 files changed, 82 insertions(+), 88 deletions(-) create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_label.dart create mode 100644 lib/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_title.dart diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart index d5002ce2f..14b05dc90 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_custom_zone.dart @@ -1,5 +1,7 @@ import 'package:fluffychat/pangea/models/bot_options_model.dart'; import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_custom_system_prompt_input.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_label.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_title.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -18,32 +20,12 @@ class ConversationBotCustomZone extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - const SizedBox(height: 12), - Text( - L10n.of(context)!.conversationBotCustomZone_title, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), + ConversationBotDynamicZoneTitle( + title: L10n.of(context)!.conversationBotCustomZone_title, ), - 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)! - .conversationBotCustomZone_customSystemPromptLabel, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - ), + ConversationBotDynamicZoneLabel( + label: L10n.of(context)! + .conversationBotCustomZone_customSystemPromptLabel, ), Padding( padding: const EdgeInsets.all(8), diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart index 2bb4d7a76..6035faf4d 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_discussion_zone.dart @@ -1,6 +1,8 @@ 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:fluffychat/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_label.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_title.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -19,32 +21,12 @@ class ConversationBotDiscussionZone extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - const SizedBox(height: 12), - Text( - L10n.of(context)!.conversationBotDiscussionZone_title, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), + ConversationBotDynamicZoneTitle( + title: L10n.of(context)!.conversationBotDiscussionZone_title, ), - 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, - ), - ), - ), + ConversationBotDynamicZoneLabel( + label: L10n.of(context)! + .conversationBotDiscussionZone_discussionTopicLabel, ), Padding( padding: const EdgeInsets.all(8), @@ -54,19 +36,9 @@ class ConversationBotDiscussionZone extends StatelessWidget { ), ), 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, - ), - ), - ), + ConversationBotDynamicZoneLabel( + label: L10n.of(context)! + .conversationBotDiscussionZone_discussionKeywordsLabel, ), Padding( padding: const EdgeInsets.all(8), diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_label.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_label.dart new file mode 100644 index 000000000..6c2043dcd --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_label.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class ConversationBotDynamicZoneLabel extends StatelessWidget { + final String label; + + const ConversationBotDynamicZoneLabel({ + super.key, + required this.label, + }); + + @override + Widget build(BuildContext context) { + return Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.fromLTRB(12, 0, 0, 0), + child: Text( + label, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + ), + ); + } +} diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_title.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_title.dart new file mode 100644 index 000000000..dbfbb00dc --- /dev/null +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_title.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; + +class ConversationBotDynamicZoneTitle extends StatelessWidget { + final String title; + + const ConversationBotDynamicZoneTitle({ + super.key, + required this.title, + }); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + const SizedBox(height: 12), + Text( + title, + style: TextStyle( + color: Theme.of(context).colorScheme.secondary, + fontWeight: FontWeight.bold, + ), + ), + const Divider( + color: Colors.grey, + thickness: 1, + ), + const SizedBox(height: 12), + ], + ); + } +} diff --git a/lib/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart b/lib/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart index 0792295e9..effbf70ee 100644 --- a/lib/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart +++ b/lib/pangea/widgets/conversation_bot/conversation_bot_text_adventure_zone.dart @@ -1,4 +1,6 @@ import 'package:fluffychat/pangea/models/bot_options_model.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_label.dart'; +import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_dynamic_zone_title.dart'; import 'package:fluffychat/pangea/widgets/conversation_bot/conversation_bot_text_adventure_game_master_instruction_input.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -18,32 +20,12 @@ class ConversationBotTextAdventureZone extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - const SizedBox(height: 12), - Text( - L10n.of(context)!.conversationBotTextAdventureZone_title, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), + ConversationBotDynamicZoneTitle( + title: L10n.of(context)!.conversationBotTextAdventureZone_title, ), - 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)! - .conversationBotTextAdventureZone_instructionLabel, - style: TextStyle( - color: Theme.of(context).colorScheme.secondary, - fontWeight: FontWeight.bold, - ), - ), - ), + ConversationBotDynamicZoneLabel( + label: L10n.of(context)! + .conversationBotTextAdventureZone_instructionLabel, ), Padding( padding: const EdgeInsets.all(8),