@@ -20,7 +20,6 @@ class _SubscriptionViewState extends State<SubscriptionView> {
2020 final String settingsPath = '/data/adb/mihomo/settings.yaml' ;
2121 final String rewritePath = '/data/adb/mihomo/rewrite.yaml' ;
2222 final String configPath = '/data/adb/mihomo/config.yaml' ;
23-
2423 String formatGB (int bytes) => (bytes / 1024 / 1024 / 1024 ).toStringAsFixed (1 );
2524
2625 @override
@@ -124,24 +123,29 @@ class _SubscriptionViewState extends State<SubscriptionView> {
124123 }
125124 }
126125 }
126+
127127 /// 删除指定订阅
128- Future <void > _deleteSubscription (BuildContext context, SubscriptionInfo sub) async {
128+ Future <void > _deleteSubscription (
129+ BuildContext context,
130+ SubscriptionInfo sub,
131+ ) async {
129132 final confirm = await showDialog <bool >(
130133 context: context,
131- builder: (_) => AlertDialog (
132- title: const Text ('确认删除' ),
133- content: Text ('确定删除订阅 "${sub .label }" 吗?' ),
134- actions: [
135- TextButton (
136- onPressed: () => Navigator .pop (context, false ),
137- child: const Text ('取消' ),
138- ),
139- ElevatedButton (
140- onPressed: () => Navigator .pop (context, true ),
141- child: const Text ('确认' ),
134+ builder:
135+ (_) => AlertDialog (
136+ title: const Text ('确认删除' ),
137+ content: Text ('确定删除订阅 "${sub .label }" 吗?' ),
138+ actions: [
139+ TextButton (
140+ onPressed: () => Navigator .pop (context, false ),
141+ child: const Text ('取消' ),
142+ ),
143+ ElevatedButton (
144+ onPressed: () => Navigator .pop (context, true ),
145+ child: const Text ('确认' ),
146+ ),
147+ ],
142148 ),
143- ],
144- ),
145149 );
146150
147151 if (confirm != true ) return ;
@@ -245,6 +249,8 @@ class _SubscriptionViewState extends State<SubscriptionView> {
245249 itemCount: subscriptions.length,
246250 itemBuilder: (context, index) {
247251 final sub = subscriptions[index];
252+ final totalValue = sub.total;
253+ int scale (int value) => totalValue == 0 ? 0 : (value * 100 ~ / totalValue);
248254
249255 return InkWell (
250256 onTap: () => _onSubscriptionTap (sub.id),
@@ -274,7 +280,7 @@ class _SubscriptionViewState extends State<SubscriptionView> {
274280 child: Row (
275281 children: [
276282 Expanded (
277- flex: sub.upload,
283+ flex: scale ( sub.upload) ,
278284 child: Container (
279285 decoration: BoxDecoration (
280286 color:
@@ -289,7 +295,7 @@ class _SubscriptionViewState extends State<SubscriptionView> {
289295 ),
290296 ),
291297 Expanded (
292- flex: sub.download,
298+ flex: scale ( sub.download) ,
293299 child: Container (
294300 color:
295301 Theme .of (
@@ -298,7 +304,10 @@ class _SubscriptionViewState extends State<SubscriptionView> {
298304 ),
299305 ),
300306 Expanded (
301- flex: sub.total - sub.upload - sub.download,
307+ flex:
308+ 100 -
309+ scale (sub.upload) -
310+ scale (sub.download),
302311 child: Container (
303312 decoration: const BoxDecoration (
304313 color: Colors .grey,
@@ -340,7 +349,8 @@ class _SubscriptionViewState extends State<SubscriptionView> {
340349 Icons .delete_outlined,
341350 size: 20 ,
342351 ),
343- onPressed: () => _deleteSubscription (context,sub),
352+ onPressed:
353+ () => _deleteSubscription (context, sub),
344354 ),
345355 ],
346356 ),
0 commit comments