mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +01:00
feat: long press repo item
This commit is contained in:
parent
4bc2319ec6
commit
e35d5dfb3a
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:fimber/fimber.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class DialogOption<T> {
|
||||
@ -290,4 +291,34 @@ class ThemeModel with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showActions(BuildContext context, List<ActionItem> actionItems) async {
|
||||
final value = await showCupertinoModalPopup<int>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoActionSheet(
|
||||
title: Text('Actions'),
|
||||
actions: actionItems.asMap().entries.map((entry) {
|
||||
return CupertinoActionSheetAction(
|
||||
child: Text(entry.value.text),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, entry.key);
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
child: const Text('Cancel'),
|
||||
isDefaultAction: true,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (value != null) {
|
||||
actionItems[value].onPress(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
import 'package:primer/primer.dart';
|
||||
import '../screens/issue.dart';
|
||||
@ -79,33 +81,8 @@ class EventItem extends StatelessWidget {
|
||||
onLongPress: () async {
|
||||
if (actionItems == null) return;
|
||||
|
||||
final value = await showCupertinoModalPopup<int>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return CupertinoActionSheet(
|
||||
title: Text('Actions'),
|
||||
actions: actionItems.asMap().entries.map((entry) {
|
||||
return CupertinoActionSheetAction(
|
||||
child: Text(entry.value.text),
|
||||
onPressed: () {
|
||||
Navigator.pop(context, entry.key);
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
child: const Text('Cancel'),
|
||||
isDefaultAction: true,
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (value != null) {
|
||||
actionItems[value].onPress(context);
|
||||
}
|
||||
await Provider.of<ThemeModel>(context)
|
||||
.showActions(context, actionItems);
|
||||
},
|
||||
child: Container(
|
||||
padding: CommonStyle.padding,
|
||||
|
@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../utils/utils.dart';
|
||||
import 'link.dart';
|
||||
|
||||
@ -163,6 +165,12 @@ class RepositoryItem extends StatelessWidget {
|
||||
// TODO: text style
|
||||
return Link(
|
||||
screenBuilder: inRepoScreen ? null : screenBuilder,
|
||||
onLongPress: () async {
|
||||
await Provider.of<ThemeModel>(context).showActions(context, [
|
||||
ActionItem.user(owner),
|
||||
ActionItem.repository(owner, name),
|
||||
]);
|
||||
},
|
||||
child: Container(
|
||||
padding: CommonStyle.padding,
|
||||
child: Row(
|
||||
|
Loading…
x
Reference in New Issue
Block a user