mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-04-28 10:28:58 -05:00
feat: show branches count
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user