"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?; final id = settings.arguments as int?;
if (id != null) { if (id != null) {
pr.getAnAssistant(id: id); pr.getAnAssistant(id: id);
} else {
pr.getImageToolsBots();
} }
return pr; return pr;
}, },

View File

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

View File

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

View File

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

View File

@ -29,6 +29,7 @@ class _InfoPageState extends State<InfoPage> {
return Scaffold( return Scaffold(
appBar: HoshanAppBar( appBar: HoshanAppBar(
withActions: false, withActions: false,
withInfo: false,
onBack: () => Navigator.pop(context), onBack: () => Navigator.pop(context),
), ),
body: Consumer<InfoState>(builder: (context, state, child) { body: Consumer<InfoState>(builder: (context, state, child) {
@ -53,17 +54,18 @@ class _InfoPageState extends State<InfoPage> {
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
child: Column( child: Column(
children: [ children: [
Center( if (state.infoModel.title != null)
child: Padding( Center(
padding: const EdgeInsets.only(top: 32, bottom: 24), child: Padding(
child: DidvanText( padding: const EdgeInsets.only(top: 32, bottom: 24),
state.infoModel.title ?? 'آموزش پرامپت نویسی اصولی', child: DidvanText(
fontSize: 20, state.infoModel.title!,
fontWeight: FontWeight.bold, fontSize: 20,
color: Theme.of(context).colorScheme.checkFav, fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.checkFav,
),
), ),
), ),
),
if (state.infoModel.url != null) if (state.infoModel.url != null)
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0), padding: const EdgeInsets.symmetric(horizontal: 20.0),
@ -76,6 +78,34 @@ class _InfoPageState extends State<InfoPage> {
), ),
), ),
), ),
if (state.infoModel.url != null)
Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Row(
children: [
DidvanText(
'آنچه در این ویدیو خواهید دید:',
fontSize: 16,
),
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount:
state.infoModel.description!.length,
itemBuilder: (context, index) => summery(
state.infoModel.description?[index] ??
''),
))
],
),
),
if (state.infoModel.pdf != null) if (state.infoModel.pdf != null)
Padding( Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 0), padding: const EdgeInsets.fromLTRB(20, 20, 20, 0),
@ -87,31 +117,6 @@ class _InfoPageState extends State<InfoPage> {
}, },
), ),
), ),
Padding(
padding: const EdgeInsets.all(20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Row(
children: [
DidvanText(
'آنچه در این ویدیو خواهید دید:',
fontSize: 16,
),
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: state.infoModel.description!.length,
itemBuilder: (context, index) => summery(
state.infoModel.description?[index] ?? ''),
))
],
),
),
], ],
), ),
), ),

View File

@ -87,10 +87,12 @@ class _ToolScreenState extends State<ToolScreen> {
height: 4, height: 4,
), ),
DidvanText( DidvanText(
bot.name!, bot.name ?? '',
fontSize: 16, fontSize: 16,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.text, color: Theme.of(context).colorScheme.text,
maxLines: 1,
overflow: TextOverflow.ellipsis,
), ),
if (bot.short != null) if (bot.short != null)
Column( 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/ai/tools_state.dart';
import 'package:didvan/views/widgets/didvan/text.dart'; import 'package:didvan/views/widgets/didvan/text.dart';
import 'package:didvan/views/widgets/shimmer_placeholder.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:didvan/views/widgets/state_handlers/empty_state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
@ -54,9 +55,22 @@ class _ToolsScreenState extends State<ToolsScreen> {
if (state.loading) { if (state.loading) {
return toolsPlaceHolder(); 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( return ListView.builder(
itemCount: tools!.length, itemCount: tools.length,
shrinkWrap: true, shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 24) padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 24)
.copyWith(bottom: 46), .copyWith(bottom: 46),
@ -94,10 +108,14 @@ class _ToolsScreenState extends State<ToolsScreen> {
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
children: [ children: [
DidvanText( Expanded(
tool.name!, child: DidvanText(
fontSize: 16, tool.name ?? '',
fontWeight: FontWeight.bold, fontSize: 16,
fontWeight: FontWeight.bold,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
), ),
Container( Container(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
@ -119,17 +137,22 @@ class _ToolsScreenState extends State<ToolsScreen> {
), ),
DidvanText( DidvanText(
'${tool.bots!.map( '${tool.bots!.map(
(e) => e.name!, (e) => e.name!,
)}' ).take(3)}'
.replaceAll('(', '') .replaceAll('(', '')
.replaceAll(')', ''), .replaceAll(')', ''),
fontSize: 12, fontSize: 12,
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
maxLines: 1,
overflow: TextOverflow.ellipsis,
), ),
DidvanText(tool.description!, DidvanText(
fontSize: 12, tool.description ?? '',
color: fontSize: 12,
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) { Widget recorderAndTextMessageHandler(
return Row( BuildContext context, AiChatState state) {
crossAxisAlignment: CrossAxisAlignment.end, return _mRecorder!.isPaused
children: _mRecorder!.isPaused ? Row(
? [ crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded( Expanded(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -345,9 +346,12 @@ class _AiMessageBarState extends State<AiMessageBar> {
}); });
}, },
) )
] ],
: _mRecorder!.isRecording )
? [ : _mRecorder!.isRecording
? Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded( Expanded(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@ -372,8 +376,11 @@ class _AiMessageBarState extends State<AiMessageBar> {
}); });
}, },
) )
] ],
: [ )
: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded( Expanded(
child: state.file != null && state.file!.isRecorded child: state.file != null && state.file!.isRecorded
? audioContainer() ? audioContainer()
@ -417,7 +424,7 @@ class _AiMessageBarState extends State<AiMessageBar> {
]), ]),
) )
], ],
); );
} }
TextFormField edittext(BuildContext context, AiChatState state) { TextFormField edittext(BuildContext context, AiChatState state) {
@ -446,7 +453,7 @@ class _AiMessageBarState extends State<AiMessageBar> {
}, },
child: const Icon(DidvanIcons.close_circle_solid), 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/routes/routes.dart';
import 'package:didvan/utils/action_sheet.dart'; import 'package:didvan/utils/action_sheet.dart';
import 'package:didvan/views/ai/history_ai_chat_state.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/divider.dart';
import 'package:didvan/views/widgets/didvan/text.dart'; import 'package:didvan/views/widgets/didvan/text.dart';
import 'package:didvan/views/widgets/shimmer_placeholder.dart'; import 'package:didvan/views/widgets/shimmer_placeholder.dart';
@ -20,7 +19,8 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class HoshanDrawer extends StatefulWidget { 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 @override
State<HoshanDrawer> createState() => _HoshanDrawerState(); State<HoshanDrawer> createState() => _HoshanDrawerState();
@ -48,7 +48,7 @@ class _HoshanDrawerState extends State<HoshanDrawer> {
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
InkWell( InkWell(
onTap: () => homeScaffKey.currentState!.closeDrawer(), onTap: () => widget.scaffKey?.currentState?.closeDrawer(),
child: const Icon( child: const Icon(
DidvanIcons.close_regular, DidvanIcons.close_regular,
), ),

View File

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

View File

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

View File

@ -15,8 +15,10 @@ import 'package:provider/provider.dart';
class HoshanAppBar extends StatelessWidget implements PreferredSizeWidget { class HoshanAppBar extends StatelessWidget implements PreferredSizeWidget {
final Function()? onBack; final Function()? onBack;
final bool withInfo;
final bool withActions; 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); : super(key: key);
@override @override
@ -57,7 +59,7 @@ class HoshanAppBar extends StatelessWidget implements PreferredSizeWidget {
), ),
Row( Row(
children: [ children: [
if (withActions) if (withInfo)
DidvanIconButton( DidvanIconButton(
icon: DidvanIcons.info_circle_light, icon: DidvanIcons.info_circle_light,
size: 32, 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.dart';
import 'package:didvan/services/network/request_helper.dart'; import 'package:didvan/services/network/request_helper.dart';
import 'package:didvan/views/widgets/shimmer_placeholder.dart'; import 'package:didvan/views/widgets/shimmer_placeholder.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// ignore: depend_on_referenced_packages // ignore: depend_on_referenced_packages
import 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'; 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, borderRadius: borderRadius ?? BorderRadius.zero,
child: CachedNetworkImage( child: CachedNetworkImage(
errorWidget: (context, url, error) { errorWidget: (context, url, error) {
if (kDebugMode) {
print('image fetch compelete with Error: $error');
}
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.disabledBackground), 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. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 3.3.6+3360 version: 3.3.7+3370
environment: environment:
sdk: ">=2.19.0 <3.0.0" sdk: ">=2.19.0 <3.0.0"