"Updated various files in the lib/views directory, including route_generator, ai_chat_page, create_bot_assistants_page, and others, with changes to UI, layout, and functionality."

This commit is contained in:
OkaykOrhmn 2024-11-25 15:16:47 +03:30
parent 705d9fb8ab
commit b0d6566ac3
14 changed files with 127 additions and 74 deletions

View File

@ -330,6 +330,8 @@ class RouteGenerator {
final id = settings.arguments as int?;
if (id != null) {
pr.getAnAssistant(id: id);
} else {
pr.getImageToolsBots();
}
return pr;
},

View File

@ -111,7 +111,9 @@ class _AiChatPageState extends State<AiChatPage> {
),
key: scaffKey,
resizeToAvoidBottomInset: true,
drawer: const HoshanDrawer(),
drawer: HoshanDrawer(
scaffKey: scaffKey,
),
body: state.loading
? Center(
child: Image.asset(
@ -166,7 +168,10 @@ class _AiChatPageState extends State<AiChatPage> {
.caption,
textAlign: TextAlign.justify,
)),
)
),
const SizedBox(
height: 100,
),
],
)
],

View File

@ -335,9 +335,9 @@ class _CreateBotAssistantsPageState extends State<CreateBotAssistantsPage> {
hintText:
'توضیح دهید چه کارهایی از این ربات بر می‌آید.',
textInputType: TextInputType.multiline,
minLine: 4,
maxLine: 4,
maxLength: 800,
minLine: 6,
maxLine: 6,
maxLength: 1000,
hasHeight: false,
showLen: true,
onChanged: (value) {
@ -357,7 +357,7 @@ class _CreateBotAssistantsPageState extends State<CreateBotAssistantsPage> {
const SizedBox(
height: 24,
),
title(text: 'نوع دستیار'),
title(text: 'انتخاب مدل'),
state.loadingImageBots
? ShimmerPlaceholder(
width: MediaQuery.sizeOf(context).width,
@ -414,7 +414,7 @@ class _CreateBotAssistantsPageState extends State<CreateBotAssistantsPage> {
hintText:
'به ربات خود بگویید که چگونه رفتار کند و چگونه به پیام‌های کاربر پاسخ دهد. سعی کنید تا حد امکان پیام واضح و مشخص باشد.',
textInputType: TextInputType.multiline,
minLine: 6,
minLine: 10,
maxLine: 10,
// maxLength: 2000,
hasHeight: false,

View File

@ -89,9 +89,10 @@ class CreateBotAssistantsState extends CoreProvier {
}
Future getAnAssistant({required final int id}) async {
await getImageToolsBots();
loading = true;
update();
await getImageToolsBots();
final service = RequestService(
RequestHelper.getAssistant(id),
);

View File

@ -29,6 +29,7 @@ class _InfoPageState extends State<InfoPage> {
return Scaffold(
appBar: HoshanAppBar(
withActions: false,
withInfo: false,
onBack: () => Navigator.pop(context),
),
body: Consumer<InfoState>(builder: (context, state, child) {
@ -53,11 +54,12 @@ class _InfoPageState extends State<InfoPage> {
physics: const BouncingScrollPhysics(),
child: Column(
children: [
if (state.infoModel.title != null)
Center(
child: Padding(
padding: const EdgeInsets.only(top: 32, bottom: 24),
child: DidvanText(
state.infoModel.title ?? 'آموزش پرامپت نویسی اصولی',
state.infoModel.title!,
fontSize: 20,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.checkFav,
@ -76,17 +78,7 @@ class _InfoPageState extends State<InfoPage> {
),
),
),
if (state.infoModel.pdf != null)
Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
child: DidvanButton(
title: 'دانلود فایل راهنما',
onPressed: () {
launchUrlString(state.infoModel.pdf!,
mode: LaunchMode.inAppBrowserView);
},
),
),
if (state.infoModel.url != null)
Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
@ -105,13 +97,26 @@ class _InfoPageState extends State<InfoPage> {
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: state.infoModel.description!.length,
itemCount:
state.infoModel.description!.length,
itemBuilder: (context, index) => summery(
state.infoModel.description?[index] ?? ''),
state.infoModel.description?[index] ??
''),
))
],
),
),
if (state.infoModel.pdf != null)
Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
child: DidvanButton(
title: 'دانلود فایل راهنما',
onPressed: () {
launchUrlString(state.infoModel.pdf!,
mode: LaunchMode.inAppBrowserView);
},
),
),
],
),
),

View File

@ -87,10 +87,12 @@ class _ToolScreenState extends State<ToolScreen> {
height: 4,
),
DidvanText(
bot.name!,
bot.name ?? '',
fontSize: 16,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
if (bot.short != null)
Column(

View File

@ -5,6 +5,7 @@ import 'package:didvan/views/ai/ai_state.dart';
import 'package:didvan/views/ai/tools_state.dart';
import 'package:didvan/views/widgets/didvan/text.dart';
import 'package:didvan/views/widgets/shimmer_placeholder.dart';
import 'package:didvan/views/widgets/state_handlers/empty_connection.dart';
import 'package:didvan/views/widgets/state_handlers/empty_state.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@ -54,9 +55,22 @@ class _ToolsScreenState extends State<ToolsScreen> {
if (state.loading) {
return toolsPlaceHolder();
}
if (tools == null) {
return Padding(
padding: EdgeInsets.only(
top: MediaQuery.sizeOf(context).height * 0.1),
child: Center(
child: EmptyConnection(
onRetry: () {
context.read<ToolsState>().getTools();
},
),
),
);
}
return ListView.builder(
itemCount: tools!.length,
itemCount: tools.length,
shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 24)
.copyWith(bottom: 46),
@ -94,10 +108,14 @@ class _ToolsScreenState extends State<ToolsScreen> {
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
DidvanText(
tool.name!,
Expanded(
child: DidvanText(
tool.name ?? '',
fontSize: 16,
fontWeight: FontWeight.bold,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
Container(
padding: const EdgeInsets.symmetric(
@ -120,16 +138,21 @@ class _ToolsScreenState extends State<ToolsScreen> {
DidvanText(
'${tool.bots!.map(
(e) => e.name!,
)}'
).take(3)}'
.replaceAll('(', '')
.replaceAll(')', ''),
fontSize: 12,
color: Theme.of(context).colorScheme.primary,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
DidvanText(tool.description!,
DidvanText(
tool.description ?? '',
fontSize: 12,
color:
Theme.of(context).colorScheme.caption)
overflow: TextOverflow.ellipsis,
color: Theme.of(context).colorScheme.caption,
maxLines: 2,
)
],
),
)

View File

@ -310,11 +310,12 @@ class _AiMessageBarState extends State<AiMessageBar> {
});
}
Row recorderAndTextMessageHandler(BuildContext context, AiChatState state) {
return Row(
Widget recorderAndTextMessageHandler(
BuildContext context, AiChatState state) {
return _mRecorder!.isPaused
? Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: _mRecorder!.isPaused
? [
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
@ -345,9 +346,12 @@ class _AiMessageBarState extends State<AiMessageBar> {
});
},
)
]
],
)
: _mRecorder!.isRecording
? [
? Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
@ -372,8 +376,11 @@ class _AiMessageBarState extends State<AiMessageBar> {
});
},
)
]
: [
],
)
: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: state.file != null && state.file!.isRecorded
? audioContainer()
@ -446,7 +453,7 @@ class _AiMessageBarState extends State<AiMessageBar> {
},
child: const Icon(DidvanIcons.close_circle_solid),
)
: const SizedBox(),
: null,
),
);
}

View File

@ -9,7 +9,6 @@ import 'package:didvan/models/view/alert_data.dart';
import 'package:didvan/routes/routes.dart';
import 'package:didvan/utils/action_sheet.dart';
import 'package:didvan/views/ai/history_ai_chat_state.dart';
import 'package:didvan/views/home/home.dart';
import 'package:didvan/views/widgets/didvan/divider.dart';
import 'package:didvan/views/widgets/didvan/text.dart';
import 'package:didvan/views/widgets/shimmer_placeholder.dart';
@ -20,7 +19,8 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class HoshanDrawer extends StatefulWidget {
const HoshanDrawer({Key? key}) : super(key: key);
final GlobalKey<ScaffoldState>? scaffKey;
const HoshanDrawer({Key? key, this.scaffKey}) : super(key: key);
@override
State<HoshanDrawer> createState() => _HoshanDrawerState();
@ -48,7 +48,7 @@ class _HoshanDrawerState extends State<HoshanDrawer> {
mainAxisAlignment: MainAxisAlignment.end,
children: [
InkWell(
onTap: () => homeScaffKey.currentState!.closeDrawer(),
onTap: () => widget.scaffKey?.currentState?.closeDrawer(),
child: const Icon(
DidvanIcons.close_regular,
),

View File

@ -189,7 +189,9 @@ class _HomeState extends State<Home>
appBar: getAppBar(),
resizeToAvoidBottomInset: false,
drawer: context.watch<HomeState>().tabController.index == 2
? const HoshanDrawer()
? HoshanDrawer(
scaffKey: homeScaffKey,
)
: null,
body: WillPopScope(
onWillPop: () async {

View File

@ -348,7 +348,7 @@ class _ProfilePageState extends State<ProfilePage> {
),
const SizedBox(height: 16),
DidvanText(
'نسخه نرم‌افزار: 3.3.6',
'نسخه نرم‌افزار: 3.3.7',
style: Theme.of(context).textTheme.bodySmall,
),
],

View File

@ -15,8 +15,10 @@ import 'package:provider/provider.dart';
class HoshanAppBar extends StatelessWidget implements PreferredSizeWidget {
final Function()? onBack;
final bool withInfo;
final bool withActions;
const HoshanAppBar({Key? key, this.onBack, this.withActions = true})
const HoshanAppBar(
{Key? key, this.onBack, this.withActions = true, this.withInfo = true})
: super(key: key);
@override
@ -57,7 +59,7 @@ class HoshanAppBar extends StatelessWidget implements PreferredSizeWidget {
),
Row(
children: [
if (withActions)
if (withInfo)
DidvanIconButton(
icon: DidvanIcons.info_circle_light,
size: 32,

View File

@ -4,6 +4,7 @@ import 'package:didvan/config/theme_data.dart';
import 'package:didvan/services/network/request.dart';
import 'package:didvan/services/network/request_helper.dart';
import 'package:didvan/views/widgets/shimmer_placeholder.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
// ignore: depend_on_referenced_packages
import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart';
@ -34,6 +35,9 @@ class SkeletonImage extends StatelessWidget {
borderRadius: borderRadius ?? BorderRadius.zero,
child: CachedNetworkImage(
errorWidget: (context, url, error) {
if (kDebugMode) {
print('image fetch compelete with Error: $error');
}
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.disabledBackground),

View File

@ -15,7 +15,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.3.6+3360
version: 3.3.7+3370
environment:
sdk: ">=2.19.0 <3.0.0"