Rewrite http client

This commit is contained in:
2024-05-02 12:16:01 +08:00
parent d968169e42
commit 3089e1f8d2
8 changed files with 121 additions and 64 deletions

View File

@@ -73,28 +73,15 @@ class _ChatIndexScreenState extends State<ChatIndexScreen> {
),
],
)
: ChatIndexScreenWidget(
onSelect: (item) async {
final result = await router.pushNamed(
'chat.channel',
pathParameters: {
'channel': item.alias,
},
);
switch (result) {
case 'refresh':
// fetchChannels();
}
},
),
: const ChatIndexScreenWidget(),
);
}
}
class ChatIndexScreenWidget extends StatefulWidget {
final Function(Channel item) onSelect;
final Function(Channel item)? onSelect;
const ChatIndexScreenWidget({super.key, required this.onSelect});
const ChatIndexScreenWidget({super.key, this.onSelect});
@override
State<ChatIndexScreenWidget> createState() => _ChatIndexScreenWidgetState();
@@ -176,7 +163,23 @@ class _ChatIndexScreenWidgetState extends State<ChatIndexScreenWidget> {
),
title: Text(element.name),
subtitle: Text(element.description),
onTap: () => widget.onSelect(element),
onTap: () async {
if (widget.onSelect != null) {
widget.onSelect!(element);
return;
}
final result = await router.pushNamed(
'chat.channel',
pathParameters: {
'channel': element.alias,
},
);
switch (result) {
case 'refresh':
fetchChannels();
}
},
);
},
),

View File

@@ -175,9 +175,9 @@ class _CommentEditorScreenState extends State<CommentEditorScreen> {
),
widget.editing != null ? editingBanner : Container(),
Container(
decoration: const BoxDecoration(
decoration: BoxDecoration(
border: Border(
top: BorderSide(width: 0.3, color: Color(0xffdedede)),
top: BorderSide(width: 0.3, color: Theme.of(context).dividerColor),
),
),
child: Row(

View File

@@ -165,9 +165,9 @@ class _MomentEditorScreenState extends State<MomentEditorScreen> {
),
widget.editing != null ? editingBanner : Container(),
Container(
decoration: const BoxDecoration(
decoration: BoxDecoration(
border: Border(
top: BorderSide(width: 0.3, color: Color(0xffdedede)),
top: BorderSide(width: 0.3, color: Theme.of(context).dividerColor),
),
),
child: Row(