feat: show branches count

This commit is contained in:
Rongjian Zhang
2019-09-23 17:08:51 +08:00
parent 7562f391cc
commit 4fb32fa818
4 changed files with 101 additions and 68 deletions

View File

@@ -1,6 +1,8 @@
import 'dart:io';
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:git_touch/widgets/picker.dart';
import 'package:shared_preferences/shared_preferences.dart';
class DialogOption<T> {
@@ -180,4 +182,50 @@ class ThemeModel with ChangeNotifier {
);
}
}
static Timer _debounce;
showPicker(BuildContext context, PickerGroupItem<String> groupItem) async {
switch (theme) {
case AppThemeType.cupertino:
await showCupertinoModalPopup<void>(
context: context,
builder: (context) {
return Container(
height: 300,
child: CupertinoPicker(
backgroundColor: CupertinoColors.white,
children: groupItem.items.map((v) => Text(v.text)).toList(),
itemExtent: 40,
scrollController: FixedExtentScrollController(
initialItem: groupItem.items
.toList()
.indexWhere((v) => v.value == groupItem.value)),
onSelectedItemChanged: (index) {
if (_debounce?.isActive ?? false) _debounce.cancel();
_debounce = Timer(const Duration(milliseconds: 500), () {
return groupItem
.onChange(groupItem.items.toList()[index].value);
});
},
),
);
},
);
break;
default:
final value = await showMenu(
context: context,
initialValue: groupItem.value,
items: groupItem.items
.map((item) =>
PopupMenuItem(value: item.value, child: Text(item.text)))
.toList(),
position: RelativeRect.fill,
);
if (value != null) {
groupItem.onChange(value);
}
}
}
}