Files
gopeed/ui/flutter/lib/app/views/breadcrumb_view.dart
T
Levi c0cd2d7255 feat: task file manage (#196)
1. support view task file list
2. support share file on android and iOS
2023-09-04 13:51:30 +08:00

60 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
class Breadcrumb extends StatelessWidget {
final List<String> items;
final Function(int)? onItemTap;
final TextStyle textStyle;
final TextStyle activeTextStyle;
const Breadcrumb({
super.key,
required this.items,
this.onItemTap,
this.textStyle = const TextStyle(fontSize: 16),
this.activeTextStyle =
const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
});
@override
Widget build(BuildContext context) {
List<Widget> children = [];
for (int i = 0; i < items.length; i++) {
children.add(
GestureDetector(
onTap: () {
if (onItemTap != null) {
onItemTap!(i);
}
},
child: Text(
items[i],
style: i == items.length - 1 ? activeTextStyle : textStyle,
),
),
);
if (i != items.length - 1) {
children.add(const Text(" > "));
}
}
return Row(
children: [
...(children.length == 1
? children.sublist(0, 1)
: children.sublist(0, 2)),
children.length > 2
? Expanded(
child: SingleChildScrollView(
reverse: true,
scrollDirection: Axis.horizontal,
child: Row(
children: children.sublist(2),
),
),
)
: null,
].where((e) => e != null).map((e) => e!).toList(),
).paddingOnly(right: 12);
}
}