Skip to content

Commit 61e40af

Browse files
committed
去掉未展开时的TabBar上的小圆点,缩窄间距,对指示条、文本进行染色,并加粗文本使文本颜色更易察觉。
1 parent 7c06945 commit 61e40af

File tree

1 file changed

+56
-48
lines changed

1 file changed

+56
-48
lines changed

lib/pages/info/source_sheet.dart

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -252,59 +252,67 @@ class _SourceSheetState extends State<SourceSheet> with SingleTickerProviderStat
252252
child: Row(
253253
children: [
254254
Expanded(
255-
child: TabBar(
256-
isScrollable: true,
257-
tabAlignment: TabAlignment.center,
258-
dividerHeight: 0,
259-
controller: widget.tabController,
260-
tabs: pluginsController.pluginList
261-
.map(
262-
(plugin) => Observer(
263-
builder: (context) => Tab(
264-
child: Row(
265-
children: [
266-
Text(
267-
plugin.name,
268-
overflow: TextOverflow.ellipsis,
269-
style: TextStyle(
255+
child: Observer(
256+
builder: (context) => TabBar(
257+
isScrollable: true,
258+
tabAlignment: TabAlignment.center,
259+
dividerHeight: 0,
260+
controller: widget.tabController,
261+
labelPadding: const EdgeInsets.symmetric(horizontal: 10.0),
262+
indicatorColor: (() {
263+
final list = pluginsController.pluginList;
264+
final idx = widget.tabController.index;
265+
if (idx < 0 || idx >= list.length) {
266+
return Theme.of(context).colorScheme.secondary;
267+
}
268+
final status = widget.infoController.pluginSearchStatus[list[idx].name];
269+
return status == 'success'
270+
? Theme.of(context).colorScheme.onSurface
271+
: Color.lerp(
272+
Theme.of(context).colorScheme.secondary,
273+
status == 'pending'
274+
? Theme.of(context).colorScheme.onSurfaceVariant
275+
: status == 'noresult'
276+
? Colors.orange
277+
: Colors.red,
278+
Theme.of(context).brightness == Brightness.dark ? 0.5 : 0.8,
279+
)!;
280+
})(),
281+
tabs: pluginsController.pluginList
282+
.asMap()
283+
.entries
284+
.map((entry) {
285+
final plugin = entry.value;
286+
final status = widget.infoController.pluginSearchStatus[plugin.name];
287+
return Tab(
288+
child: Row(
289+
children: [
290+
Text(
291+
plugin.name,
292+
overflow: TextOverflow.ellipsis,
293+
style: TextStyle(
270294
fontSize: Theme.of(context)
271295
.textTheme
272296
.titleMedium!
273297
.fontSize,
274-
color: Theme.of(context)
275-
.colorScheme
276-
.onSurface),
277-
),
278-
const SizedBox(width: 5.0),
279-
Container(
280-
width: 8.0,
281-
height: 8.0,
282-
decoration: BoxDecoration(
283-
color: widget.infoController
284-
.pluginSearchStatus[
285-
plugin.name] ==
286-
'success'
287-
? Colors.green
288-
: (widget.infoController
289-
.pluginSearchStatus[
290-
plugin.name] ==
291-
'pending')
292-
? Theme.of(context).colorScheme.onSurfaceVariant
293-
: (widget.infoController
294-
.pluginSearchStatus[
295-
plugin.name] ==
296-
'noresult')
297-
? Colors.orange
298-
: Colors.red,
299-
shape: BoxShape.circle,
298+
fontWeight: FontWeight.bold,
299+
color: status == 'success'
300+
? Theme.of(context).colorScheme.onSurface
301+
: Color.lerp(
302+
Theme.of(context).colorScheme.onSurface,
303+
status == 'pending'
304+
? Theme.of(context).colorScheme.onSurfaceVariant
305+
: status == 'noresult'
306+
? Colors.orange
307+
: Colors.red,
308+
Theme.of(context).brightness == Brightness.dark ? 0.5 : 0.8,)
309+
),
300310
),
301-
),
302-
],
303-
),
304-
),
305-
),
306-
)
307-
.toList(),
311+
],
312+
),
313+
);
314+
}).toList(),
315+
),
308316
),
309317
),
310318
IconButton(

0 commit comments

Comments
 (0)