git-touch-android-ios-app/lib/scaffolds/tab.dart

54 lines
1.5 KiB
Dart
Raw Normal View History

2019-09-24 13:58:34 +02:00
import 'package:flutter/cupertino.dart';
2019-10-02 08:58:11 +02:00
import 'package:git_touch/scaffolds/common.dart';
2019-09-25 11:06:36 +02:00
import 'package:git_touch/scaffolds/utils.dart';
2019-09-24 13:58:34 +02:00
2019-09-25 11:06:36 +02:00
class TabScaffold extends StatelessWidget {
final Widget title;
final Widget body;
2021-05-16 09:16:35 +02:00
final Widget? action;
2019-09-25 11:06:36 +02:00
final void Function() onRefresh;
2019-09-25 12:47:34 +02:00
final List<String> tabs;
final int activeTab;
final Function(int index) onTabSwitch;
2019-09-24 13:58:34 +02:00
2022-09-06 18:28:12 +02:00
const TabScaffold({
2021-05-16 09:16:35 +02:00
required this.title,
required this.body,
2019-10-03 04:01:54 +02:00
this.action,
2021-05-16 09:16:35 +02:00
required this.onRefresh,
required this.tabs,
required this.activeTab,
required this.onTabSwitch,
2019-09-24 13:58:34 +02:00
});
@override
Widget build(BuildContext context) {
2022-09-17 14:35:45 +02:00
return CommonScaffold(
title: DefaultTextStyle(
style: DefaultTextStyle.of(context).style.copyWith(fontSize: 14),
child: Row(
children: [
Expanded(
child: CupertinoSlidingSegmentedControl<int>(
groupValue: activeTab,
onValueChanged: (v) {
if (v == null) return;
onTabSwitch(v);
},
children: tabs.asMap().map((key, text) => MapEntry(
key,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text(text),
))),
),
),
],
),
),
2019-09-25 11:06:36 +02:00
body: RefreshWrapper(body: body, onRefresh: onRefresh),
2020-01-27 03:47:34 +01:00
// action: action, // TODO:
2019-09-25 11:06:36 +02:00
);
2019-09-24 13:58:34 +02:00
}
}