"Updated AI models, routes, and UI components, including adding new fields, modifying widget layouts, and adjusting text styles."
This commit is contained in:
parent
28b9d7efb7
commit
2663a8b98e
|
|
@ -4,6 +4,7 @@ class BotsModel {
|
|||
String? image;
|
||||
String? responseType;
|
||||
String? description;
|
||||
String? short;
|
||||
List<String>? attachmentType;
|
||||
int? attachment;
|
||||
bool? editable;
|
||||
|
|
@ -23,6 +24,7 @@ class BotsModel {
|
|||
name = json['name'];
|
||||
image = json['image'];
|
||||
description = json['description'];
|
||||
short = json['short'];
|
||||
if (json['attachmentType'] != null) {
|
||||
attachmentType = <String>[];
|
||||
json['attachmentType'].forEach((v) {
|
||||
|
|
@ -40,6 +42,7 @@ class BotsModel {
|
|||
data['name'] = name;
|
||||
data['image'] = image;
|
||||
data['description'] = description;
|
||||
data['short'] = short;
|
||||
if (attachmentType != null) {
|
||||
data['attachmentType'] = attachmentType!.map((v) => v).toList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
class InfoModel {
|
||||
String? url;
|
||||
String? title;
|
||||
List<String>? description;
|
||||
|
||||
InfoModel({this.url, this.title, this.description});
|
||||
|
||||
InfoModel.fromJson(Map<String, dynamic> json) {
|
||||
url = json['url'];
|
||||
title = json['title'];
|
||||
description = json['description'].cast<String>();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['url'] = url;
|
||||
data['title'] = title;
|
||||
data['description'] = description;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import 'package:didvan/views/ai/create_bot_assistants_state.dart';
|
|||
import 'package:didvan/views/ai/history_ai_chat_page.dart';
|
||||
import 'package:didvan/views/ai/history_ai_chat_state.dart';
|
||||
import 'package:didvan/views/ai/info_page.dart';
|
||||
import 'package:didvan/views/ai/info_state.dart';
|
||||
import 'package:didvan/views/authentication/authentication.dart';
|
||||
import 'package:didvan/views/authentication/authentication_state.dart';
|
||||
import 'package:didvan/views/comments/comments.dart';
|
||||
|
|
@ -337,7 +338,13 @@ class RouteGenerator {
|
|||
),
|
||||
));
|
||||
case Routes.info:
|
||||
return _createRoute(const InfoPage());
|
||||
return _createRoute(ChangeNotifierProvider<InfoState>(
|
||||
create: (context) {
|
||||
InfoState infoState = InfoState();
|
||||
infoState.getTools();
|
||||
return infoState;
|
||||
},
|
||||
child: const InfoPage()));
|
||||
|
||||
case Routes.web:
|
||||
return _createRoute(WebView(
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ class RequestHelper {
|
|||
static String archivedChat(int id) => '$baseUrl/ai/chat/$id/archive';
|
||||
static String placeholder(int id) => '$baseUrl/ai/chat/$id/placeholder';
|
||||
static String tools() => '$baseUrl/ai/tool';
|
||||
static String info() => '$baseUrl/ai/video';
|
||||
static String usersAssistants({final bool personal = false}) =>
|
||||
'$baseUrl/ai/user/bot${_urlConcatGenerator([
|
||||
MapEntry('personal', personal),
|
||||
|
|
|
|||
|
|
@ -159,8 +159,13 @@ class _AiChatPageState extends State<AiChatPage> {
|
|||
horizontal: 20.0),
|
||||
child: Center(
|
||||
child: DidvanText(
|
||||
widget.args.bot.description ??
|
||||
'')),
|
||||
widget.args.bot.description ?? '',
|
||||
fontSize: 12,
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.caption,
|
||||
textAlign: TextAlign.justify,
|
||||
)),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ class _CreateBotAssistantsPageState extends State<CreateBotAssistantsPage> {
|
|||
textInputType: TextInputType.multiline,
|
||||
minLine: 6,
|
||||
maxLine: 6,
|
||||
maxLength: 400,
|
||||
maxLength: 2000,
|
||||
hasHeight: false,
|
||||
showLen: true,
|
||||
onChanged: (value) {
|
||||
|
|
@ -679,6 +679,7 @@ class _CreateBotAssistantsPageState extends State<CreateBotAssistantsPage> {
|
|||
itemBuilder: (context, index) => Column(
|
||||
children: [
|
||||
DidvanTextField(
|
||||
textAlign: TextAlign.left,
|
||||
onChanged: (value) {
|
||||
state.countOfLink[index] = value;
|
||||
if (state.countOfLink[index]
|
||||
|
|
@ -691,8 +692,7 @@ class _CreateBotAssistantsPageState extends State<CreateBotAssistantsPage> {
|
|||
state.update();
|
||||
},
|
||||
// validator: (value) {},
|
||||
hintText:
|
||||
'https://www.weforum.org/agenda/2024/08',
|
||||
hintText: 'https://www.weforum.org',
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
import 'package:didvan/config/design_config.dart';
|
||||
import 'package:didvan/config/theme_data.dart';
|
||||
import 'package:didvan/constants/app_icons.dart';
|
||||
import 'package:didvan/models/enums.dart';
|
||||
import 'package:didvan/routes/routes.dart';
|
||||
import 'package:didvan/views/ai/info_state.dart';
|
||||
import 'package:didvan/views/widgets/didvan/divider.dart';
|
||||
import 'package:didvan/views/widgets/didvan/text.dart';
|
||||
import 'package:didvan/views/widgets/hoshan_app_bar.dart';
|
||||
import 'package:didvan/views/widgets/video/chat_video_player.dart';
|
||||
import 'package:didvan/views/widgets/video/primary_controls.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class InfoPage extends StatefulWidget {
|
||||
const InfoPage({Key? key}) : super(key: key);
|
||||
|
|
@ -23,7 +28,16 @@ class _InfoPageState extends State<InfoPage> {
|
|||
withActions: false,
|
||||
onBack: () => Navigator.pop(context),
|
||||
),
|
||||
body: Column(
|
||||
body: Consumer<InfoState>(builder: (context, state, child) {
|
||||
if (state.appState == AppState.busy) {
|
||||
return Center(
|
||||
child: SpinKitThreeBounce(
|
||||
size: 46,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
|
|
@ -35,21 +49,21 @@ class _InfoPageState extends State<InfoPage> {
|
|||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 32, bottom: 24),
|
||||
child: DidvanText(
|
||||
'آموزش پرامپت نویسی اصولی',
|
||||
state.infoModel.title ?? 'آموزش پرامپت نویسی اصولی',
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.checkFav,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.0),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: DesignConfig.lowBorderRadius,
|
||||
child: ChatVideoPlayer(
|
||||
src:
|
||||
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4',
|
||||
src: state.infoModel.url ?? '',
|
||||
showOptions: true,
|
||||
custome: const PrimaryControls(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -68,122 +82,13 @@ class _InfoPageState extends State<InfoPage> {
|
|||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8),
|
||||
decoration: const ShapeDecoration(
|
||||
shape: CircleBorder(
|
||||
side: BorderSide(
|
||||
width: 3, color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const DidvanText(
|
||||
'انتخاب کلمات کلیدی مناسب',
|
||||
fontSize: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8),
|
||||
decoration: const ShapeDecoration(
|
||||
shape: CircleBorder(
|
||||
side: BorderSide(
|
||||
width: 3, color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const DidvanText(
|
||||
'ساختار و قالببندی پرامپتها',
|
||||
fontSize: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8),
|
||||
decoration: const ShapeDecoration(
|
||||
shape: CircleBorder(
|
||||
side: BorderSide(
|
||||
width: 3, color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const DidvanText(
|
||||
'تعیین سبک و استایل در پرامپت',
|
||||
fontSize: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8),
|
||||
decoration: const ShapeDecoration(
|
||||
shape: CircleBorder(
|
||||
side: BorderSide(
|
||||
width: 3, color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const DidvanText(
|
||||
'استفاده از جزییات و صفتها',
|
||||
fontSize: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8),
|
||||
decoration: const ShapeDecoration(
|
||||
shape: CircleBorder(
|
||||
side: BorderSide(
|
||||
width: 3, color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const DidvanText(
|
||||
'بهینهسازی پرامپتها و تکرار',
|
||||
fontSize: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8),
|
||||
decoration: const ShapeDecoration(
|
||||
shape: CircleBorder(
|
||||
side: BorderSide(
|
||||
width: 3, color: Colors.black)),
|
||||
),
|
||||
),
|
||||
const DidvanText(
|
||||
'اشتباهات رایج در پرامپتنویسی',
|
||||
fontSize: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
child: ListView.builder(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: state.infoModel.description!.length,
|
||||
itemBuilder: (context, index) => summery(
|
||||
state.infoModel.description?[index] ?? ''),
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -231,7 +136,33 @@ class _InfoPageState extends State<InfoPage> {
|
|||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Column summery(String text) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(left: 8),
|
||||
decoration: const ShapeDecoration(
|
||||
shape: CircleBorder(
|
||||
side: BorderSide(width: 3, color: Colors.black)),
|
||||
),
|
||||
),
|
||||
DidvanText(
|
||||
text,
|
||||
fontSize: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
import 'package:didvan/models/ai/info_model.dart';
|
||||
import 'package:didvan/models/enums.dart';
|
||||
import 'package:didvan/providers/core.dart';
|
||||
import 'package:didvan/services/network/request.dart';
|
||||
import 'package:didvan/services/network/request_helper.dart';
|
||||
|
||||
class InfoState extends CoreProvier {
|
||||
late InfoModel infoModel;
|
||||
void getTools() async {
|
||||
final service = RequestService(
|
||||
RequestHelper.info(),
|
||||
);
|
||||
await service.httpGet();
|
||||
if (service.isSuccess) {
|
||||
infoModel = InfoModel.fromJson(service.result);
|
||||
appState = AppState.idle;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
appState = AppState.failed;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
|
@ -50,6 +50,7 @@ class _ToolScreenState extends State<ToolScreen> {
|
|||
tool.guide!,
|
||||
fontSize: 12,
|
||||
color: Theme.of(context).colorScheme.caption,
|
||||
textAlign: TextAlign.justify,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
|
@ -91,17 +92,19 @@ class _ToolScreenState extends State<ToolScreen> {
|
|||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.text,
|
||||
),
|
||||
if (bot.description != null)
|
||||
if (bot.short != null)
|
||||
Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
DidvanText(
|
||||
bot.description!,
|
||||
fontSize: 14,
|
||||
bot.short!,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: const Color(0xffA8A6AC),
|
||||
// maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class _DidvanTextFieldState extends State<DidvanTextField> {
|
|||
onFieldSubmitted: widget.onSubmitted,
|
||||
onChanged: _onChanged,
|
||||
validator: _validator,
|
||||
maxLines: widget.maxLine,
|
||||
maxLines: _hideContent ? 1 : widget.maxLine,
|
||||
minLines: widget.minLine,
|
||||
maxLength: widget.maxLength,
|
||||
obscuringCharacter: '*',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:didvan/config/design_config.dart';
|
||||
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';
|
||||
|
|
@ -33,7 +34,10 @@ class SkeletonImage extends StatelessWidget {
|
|||
borderRadius: borderRadius ?? BorderRadius.zero,
|
||||
child: CachedNetworkImage(
|
||||
errorWidget: (context, url, error) {
|
||||
return const Text("مشکلی پیش آمده است");
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.disabledBackground),
|
||||
child: const Icon(Icons.image_not_supported_outlined));
|
||||
},
|
||||
errorListener: (value) {},
|
||||
fit: BoxFit.cover,
|
||||
|
|
|
|||
Loading…
Reference in New Issue