Skip to content

Commit

Permalink
[*]Add common announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
Muska-Ami committed Dec 28, 2023
1 parent c5ccd8f commit e994038
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/controller/dpanel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import 'package:nyalcf/dio/other/announcement.dart';

class DPanelController extends GetxController {
var announcement = '喵喵喵?正在请求捏'.obs;
var announcement_common = '喵喵喵?正在请求捏'.obs;

load() async {
announcement.value = await AnnouncementDio().get();
announcement.value = await AnnouncementDio().getBroadcast();
announcement_common.value = await AnnouncementDio().getCommon();
}
}
18 changes: 16 additions & 2 deletions lib/dio/other/announcement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import '../basicConfig.dart';
class AnnouncementDio {
final dio = Dio();

Future<String> get() async {
Future<String> getBroadcast() async {
try {
print('Get announcement');
print('Get broadcast announcement');
final response =
await dio.get('${basicConfig.api_v1_url}/App/GetBroadCast');
print(response);
Expand All @@ -18,4 +18,18 @@ class AnnouncementDio {
return '获取失败了啊呜,可能是猫猫把网线偷走了~';
}
}

Future<String> getCommon() async {
try {
print('Get common announcement');
final response =
await dio.get('${basicConfig.api_v1_url}/App');
print(response);
final Map<String, dynamic> resData = response.data;
return resData['ads'];
} catch (ex) {
print(ex);
return '获取失败了啊呜,可能是猫猫把网线偷走了~';
}
}
}
31 changes: 30 additions & 1 deletion lib/ui/panel/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,36 @@ class PanelHome extends StatelessWidget {
)
],
),
)
),
Container(
child: Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: Icon(Icons.access_time),
title: Text('通知'),
),
Flexible(
fit: FlexFit.loose,
child: Container(
margin: EdgeInsets.only(
left: 15.0,
right: 15.0,
bottom: 15.0),
child: Obx(() => MarkdownBody(
selectable: true,
onTapLink: (text, url, title) {
if (url != null) {
print(
'Launch url from Announcement: ${url}');
launchUrl(Uri.parse(url));
}
},
data: '${dp_c.announcement_common}'))))
],
),
)),
])),
Expanded(
child: Card(
Expand Down

0 comments on commit e994038

Please sign in to comment.