mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-04-29 11:03:05 -05:00
refactor: branch name widget
This commit is contained in:
@@ -127,37 +127,6 @@ bool isNotNullOrEmpty(String? text) {
|
||||
return text != null && text.isNotEmpty;
|
||||
}
|
||||
|
||||
// TODO: Primer
|
||||
class PrimerBranchName extends StatelessWidget {
|
||||
|
||||
const PrimerBranchName(this.name);
|
||||
final String? name;
|
||||
|
||||
static const branchBgColor = Color(0xffeaf5ff);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 4),
|
||||
height: 16,
|
||||
decoration: const BoxDecoration(
|
||||
color: branchBgColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(3)),
|
||||
),
|
||||
child: Text(
|
||||
name!,
|
||||
style: TextStyle(
|
||||
color: theme.palette.primary,
|
||||
fontSize: 14,
|
||||
height: 1,
|
||||
fontFamily: CommonStyle.monospace,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> launchStringUrl(String? url) async {
|
||||
if (url == null) return;
|
||||
|
||||
@@ -180,7 +149,6 @@ int sortByKey<T>(T key, T a, T b) {
|
||||
const TOTAL_COUNT_FALLBACK = 999; // TODO:
|
||||
|
||||
class ListPayload<T, K> {
|
||||
|
||||
ListPayload({
|
||||
required this.cursor,
|
||||
required this.hasMore,
|
||||
|
||||
17
lib/widgets/branch_name.dart
Normal file
17
lib/widgets/branch_name.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:antd_mobile/antd_mobile.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class BranchName extends StatelessWidget {
|
||||
const BranchName(this.name, {super.key});
|
||||
final String name;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AntTag(
|
||||
fill: AntTagFill.outline,
|
||||
color: AntTheme.primary,
|
||||
round: true,
|
||||
child: Text(name),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,15 @@ import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
import 'package:git_touch/models/github.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:git_touch/widgets/branch_name.dart';
|
||||
import 'package:git_touch/widgets/issue_icon.dart';
|
||||
import 'package:git_touch/widgets/link.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/link.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
|
||||
class EventItem extends StatelessWidget {
|
||||
|
||||
const EventItem(this.e);
|
||||
final GithubEvent e;
|
||||
|
||||
@@ -132,7 +131,7 @@ class EventItem extends StatelessWidget {
|
||||
text:
|
||||
'${AppLocalizations.of(context)!.nCommitsTo(e.payload!.commits!.length)} '),
|
||||
WidgetSpan(
|
||||
child: PrimerBranchName(
|
||||
child: BranchName(
|
||||
e.payload!.ref!.replaceFirst('refs/heads/', '')),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:git_touch/widgets/link.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class TableViewHeader extends StatelessWidget {
|
||||
|
||||
const TableViewHeader(this.title, {super.key});
|
||||
final String? title;
|
||||
|
||||
|
||||
@@ -5,18 +5,17 @@ import 'package:flutter_gen/gen_l10n/S.dart';
|
||||
import 'package:git_touch/graphql/__generated__/github.data.gql.dart';
|
||||
import 'package:git_touch/graphql/__generated__/schema.schema.gql.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/branch_name.dart';
|
||||
import 'package:git_touch/widgets/comment_item.dart';
|
||||
import 'package:git_touch/widgets/hex_color_tag.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/comment_item.dart';
|
||||
|
||||
TextSpan createUserSpan(BuildContext context, String? login) {
|
||||
return createLinkSpan(context, login, '/github/$login');
|
||||
}
|
||||
|
||||
class TimelineEventItem extends StatelessWidget {
|
||||
|
||||
const TimelineEventItem({
|
||||
this.actor,
|
||||
this.iconData = Octicons.diamond,
|
||||
@@ -402,7 +401,7 @@ class TimelineItem extends StatelessWidget {
|
||||
TextSpan(
|
||||
text:
|
||||
' ${AppLocalizations.of(context)!.headRefForcedPushedEventFirstMessage} '),
|
||||
WidgetSpan(child: PrimerBranchName(p.pullRequest.headRefName)),
|
||||
WidgetSpan(child: BranchName(p.pullRequest.headRefName)),
|
||||
TextSpan(
|
||||
text:
|
||||
' ${AppLocalizations.of(context)!.headRefForcedPushedEventSecondMessage} '),
|
||||
@@ -428,7 +427,7 @@ class TimelineItem extends StatelessWidget {
|
||||
TextSpan(
|
||||
text:
|
||||
' ${AppLocalizations.of(context)!.headRefForcedPushedEventFirstMessage} '),
|
||||
WidgetSpan(child: PrimerBranchName(p.pullRequest.baseRef!.name)),
|
||||
WidgetSpan(child: BranchName(p.pullRequest.baseRef!.name)),
|
||||
TextSpan(
|
||||
text:
|
||||
' ${AppLocalizations.of(context)!.headRefForcedPushedEventSecondMessage} '),
|
||||
|
||||
Reference in New Issue
Block a user