Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
F
flutter-chat
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
songchuancai
flutter-chat
Commits
e92fe5f9
提交
e92fe5f9
authored
11月 08, 2024
作者:
songchuancai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整应用和对话页面布局
上级
056bceaf
全部展开
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
187 行增加
和
3 行删除
+187
-3
home_page.dart
lib/home_page.dart
+0
-0
main.dart
lib/main.dart
+21
-3
app_item.dart
lib/models/app_item.dart
+13
-0
apps_page.dart
lib/pages/apps_page.dart
+92
-0
chat_page.dart
lib/pages/chat_page.dart
+56
-0
pubspec.yaml
pubspec.yaml
+5
-0
没有找到文件。
lib/home_page.dart
浏览文件 @
e92fe5f9
差异被折叠。
点击展开。
lib/main.dart
浏览文件 @
e92fe5f9
...
@@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
...
@@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
import
'package:allen/pages/login_page.dart'
;
import
'package:allen/pages/login_page.dart'
;
import
'package:allen/services/storage_service.dart'
;
import
'package:allen/services/storage_service.dart'
;
import
'package:allen/models/user.dart'
;
import
'package:allen/models/user.dart'
;
import
'package:allen/models/app_item.dart'
;
import
'package:allen/pages/chat_page.dart'
;
void
main
(
)
async
{
void
main
(
)
async
{
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsFlutterBinding
.
ensureInitialized
();
...
@@ -34,10 +36,25 @@ class MyApp extends StatelessWidget {
...
@@ -34,10 +36,25 @@ class MyApp extends StatelessWidget {
return
snapshot
.
hasData
?
const
HomePage
()
:
const
LoginPage
();
return
snapshot
.
hasData
?
const
HomePage
()
:
const
LoginPage
();
},
},
),
),
routes:
{
onGenerateRoute:
(
settings
)
{
'/home'
:
(
context
)
=>
const
HomePage
(),
if
(
settings
.
name
==
'/home'
)
{
'/login'
:
(
context
)
=>
const
LoginPage
(),
return
MaterialPageRoute
(
builder:
(
context
)
=>
const
HomePage
());
}
if
(
settings
.
name
==
'/login'
)
{
return
MaterialPageRoute
(
builder:
(
context
)
=>
const
LoginPage
());
}
if
(
settings
.
name
==
'/chat'
)
{
final
args
=
settings
.
arguments
;
if
(
args
is
AppItem
)
{
return
MaterialPageRoute
(
builder:
(
context
)
=>
ChatPage
(
app:
args
),
);
}
return
MaterialPageRoute
(
builder:
(
context
)
=>
const
HomePage
());
}
return
MaterialPageRoute
(
builder:
(
context
)
=>
const
HomePage
());
},
},
);
);
}
}
}
}
\ No newline at end of file
...
...
lib/models/app_item.dart
0 → 100644
浏览文件 @
e92fe5f9
class
AppItem
{
final
String
id
;
final
String
name
;
final
String
description
;
final
String
imageUrl
;
AppItem
({
required
this
.
id
,
required
this
.
name
,
required
this
.
description
,
required
this
.
imageUrl
,
});
}
lib/pages/apps_page.dart
0 → 100644
浏览文件 @
e92fe5f9
import
'package:flutter/material.dart'
;
import
'../models/app_item.dart'
;
import
'../pallete.dart'
;
class
AppsPage
extends
StatelessWidget
{
AppsPage
({
super
.
key
});
final
List
<
AppItem
>
apps
=
[
AppItem
(
id:
'1'
,
name:
'文章助手'
,
description:
'帮助您撰写高质量的文章,提供创意和灵感'
,
imageUrl:
'assets/images/article.png'
,
),
AppItem
(
id:
'2'
,
name:
'代码专家'
,
description:
'解答编程问题,优化代码结构,提供最佳实践'
,
imageUrl:
'assets/images/code.png'
,
),
AppItem
(
id:
'3'
,
name:
'翻译助手'
,
description:
'精准翻译多国语言,支持专业术语翻译'
,
imageUrl:
'assets/images/translate.png'
,
),
AppItem
(
id:
'4'
,
name:
'数学导师'
,
description:
'解决数学问题,讲解数学概念和公式'
,
imageUrl:
'assets/images/math.png'
,
),
AppItem
(
id:
'5'
,
name:
'生活顾问'
,
description:
'提供日常生活建议,解答各类生活问题'
,
imageUrl:
'assets/images/life.png'
,
),
];
@override
Widget
build
(
BuildContext
context
)
{
return
ListView
.
builder
(
padding:
const
EdgeInsets
.
all
(
16
),
itemCount:
apps
.
length
,
itemBuilder:
(
context
,
index
)
{
final
app
=
apps
[
index
];
return
Card
(
margin:
const
EdgeInsets
.
only
(
bottom:
16
),
elevation:
2
,
child:
ListTile
(
contentPadding:
const
EdgeInsets
.
all
(
16
),
leading:
Container
(
width:
60
,
height:
60
,
decoration:
BoxDecoration
(
color:
Pallete
.
firstSuggestionBoxColor
.
withOpacity
(
0.1
),
borderRadius:
BorderRadius
.
circular
(
12
),
),
child:
Icon
(
Icons
.
apps
,
size:
30
,
color:
Pallete
.
firstSuggestionBoxColor
,
),
),
title:
Text
(
app
.
name
,
style:
const
TextStyle
(
fontSize:
18
,
fontWeight:
FontWeight
.
bold
,
),
),
subtitle:
Padding
(
padding:
const
EdgeInsets
.
only
(
top:
8
),
child:
Text
(
app
.
description
,
style:
const
TextStyle
(
fontSize:
14
),
),
),
onTap:
()
{
Navigator
.
pushNamed
(
context
,
'/chat'
,
arguments:
app
,
);
},
),
);
},
);
}
}
lib/pages/chat_page.dart
0 → 100644
浏览文件 @
e92fe5f9
import
'package:flutter/material.dart'
;
import
'../models/app_item.dart'
;
import
'../home_page.dart'
;
class
ChatPage
extends
StatelessWidget
{
final
AppItem
app
;
const
ChatPage
({
super
.
key
,
required
this
.
app
});
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
app
.
name
,
style:
const
TextStyle
(
fontSize:
18
,
fontWeight:
FontWeight
.
bold
,
),
),
Text
(
app
.
description
,
style:
const
TextStyle
(
fontSize:
12
,
fontWeight:
FontWeight
.
normal
,
),
),
],
),
leading:
IconButton
(
icon:
const
Icon
(
Icons
.
arrow_back
),
onPressed:
()
=>
Navigator
.
of
(
context
).
pop
(),
),
),
body:
HomePage
(
customTitle:
app
.
name
,
customDescription:
app
.
description
,
customImageUrl:
app
.
imageUrl
,
hideNavigation:
true
,
),
);
}
}
\ No newline at end of file
pubspec.yaml
浏览文件 @
e92fe5f9
...
@@ -70,6 +70,11 @@ flutter:
...
@@ -70,6 +70,11 @@ flutter:
assets
:
assets
:
-
assets/images/
-
assets/images/
-
assets/sounds/
-
assets/sounds/
-
assets/images/article.png
-
assets/images/code.png
-
assets/images/translate.png
-
assets/images/math.png
-
assets/images/life.png
# An image asset can refer to one or more resolution-specific "variants", see
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# https://flutter.dev/assets-and-images/#resolution-aware
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论