mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 06:44:45 +08:00
feat:riverpod 迁移 Aria2TaskNumWidget
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:starcitizen_doctor/common/conf/const_conf.dart';
|
||||
import 'package:starcitizen_doctor/provider/aria2c.dart';
|
||||
import 'package:starcitizen_doctor/widgets/widgets.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
@ -48,25 +49,7 @@ class IndexUI extends HookConsumerWidget {
|
||||
color: Colors.white.withOpacity(.6),
|
||||
),
|
||||
),
|
||||
// if (model.aria2TotalTaskNum != 0)
|
||||
// Positioned(
|
||||
// bottom: 0,
|
||||
// right: 0,
|
||||
// child: Container(
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.red,
|
||||
// borderRadius: BorderRadius.circular(12),
|
||||
// ),
|
||||
// padding: const EdgeInsets.only(
|
||||
// left: 6, right: 6, bottom: 1.5, top: 1.5),
|
||||
// child: Text(
|
||||
// "${model.aria2TotalTaskNum}",
|
||||
// style: const TextStyle(
|
||||
// fontSize: 8,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
// )),
|
||||
_makeAria2TaskNumWidget()
|
||||
],
|
||||
),
|
||||
onPressed: () {},
|
||||
@ -134,4 +117,33 @@ class IndexUI extends HookConsumerWidget {
|
||||
pageMenus.values.toList().indexWhere((element) => element == value);
|
||||
curIndexState.value = pageIndex;
|
||||
}
|
||||
|
||||
Widget _makeAria2TaskNumWidget() {
|
||||
return Consumer(
|
||||
builder: (BuildContext context, WidgetRef ref, Widget? child) {
|
||||
final aria2cState = ref.watch(aria2cModelProvider);
|
||||
if (!aria2cState.hasDownloadTask) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 6, right: 6, bottom: 1.5, top: 1.5),
|
||||
child: Text(
|
||||
"${aria2cState.aria2TotalTaskNum}",
|
||||
style: const TextStyle(
|
||||
fontSize: 8,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user