mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-05-29 07:15:55 -05:00
refactor: replace table view
This commit is contained in:
@@ -9,7 +9,6 @@ export 'package:git_touch/utils/utils.dart';
|
||||
|
||||
// This is a scaffold for infinite scroll screens
|
||||
class ListStatefulScaffold<T, K> extends StatefulWidget {
|
||||
|
||||
const ListStatefulScaffold({
|
||||
required this.title,
|
||||
required this.fetch,
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/blob_view.dart';
|
||||
import 'package:git_touch/widgets/object_tree.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:universal_io/io.dart';
|
||||
@@ -54,15 +53,13 @@ class BbObjectScreen extends StatelessWidget {
|
||||
if (pl is String) {
|
||||
return BlobView(path, text: pl);
|
||||
} else if (pl is BbTree) {
|
||||
return TableViewItemWidget(
|
||||
createObjectTreeItem(
|
||||
name: basename(pl.path),
|
||||
type: pl.type,
|
||||
// size: v.type == 'commit_file' ? v.size : null,
|
||||
size: pl.size,
|
||||
url: '/bitbucket/$owner/$name/src/$ref?path=${pl.path.urlencode}',
|
||||
downloadUrl: pl.links!['self']['href'] as String?,
|
||||
),
|
||||
return createObjectTreeItem(
|
||||
name: basename(pl.path),
|
||||
type: pl.type,
|
||||
// size: v.type == 'commit_file' ? v.size : null,
|
||||
size: pl.size,
|
||||
url: '/bitbucket/$owner/$name/src/$ref?path=${pl.path.urlencode}',
|
||||
downloadUrl: pl.links!['self']['href'] as String?,
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
|
||||
@@ -17,7 +17,6 @@ import 'package:git_touch/widgets/contribution.dart';
|
||||
import 'package:git_touch/widgets/entry_item.dart';
|
||||
import 'package:git_touch/widgets/mutation_button.dart';
|
||||
import 'package:git_touch/widgets/repository_item.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:git_touch/widgets/text_with_at.dart';
|
||||
import 'package:git_touch/widgets/user_header.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -33,27 +32,22 @@ class _Repos extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
return AntList(
|
||||
header: Text(title),
|
||||
children: [
|
||||
TableViewHeader(title),
|
||||
...join(
|
||||
CommonStyle.border,
|
||||
repos!.map((v) {
|
||||
return RepositoryItem.gh(
|
||||
owner: v.owner.login,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.stargazers.totalCount,
|
||||
forkCount: v.forks.totalCount,
|
||||
primaryLanguageName: v.primaryLanguage?.name,
|
||||
primaryLanguageColor: v.primaryLanguage?.color,
|
||||
isPrivate: v.isPrivate,
|
||||
isFork: v.isFork,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
for (final v in repos!)
|
||||
RepositoryItem.gh(
|
||||
owner: v.owner.login,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.stargazers.totalCount,
|
||||
forkCount: v.forks.totalCount,
|
||||
primaryLanguageName: v.primaryLanguage?.name,
|
||||
primaryLanguageColor: v.primaryLanguage?.color,
|
||||
isPrivate: v.isPrivate,
|
||||
isFork: v.isFork,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/object_tree.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class GlTreeScreen extends StatelessWidget {
|
||||
@@ -38,18 +37,16 @@ class GlTreeScreen extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
itemBuilder: (item) {
|
||||
return TableViewItemWidget(
|
||||
createObjectTreeItem(
|
||||
type: item.type,
|
||||
name: item.name,
|
||||
downloadUrl:
|
||||
'${auth.activeAccount!.domain}/api/v4/projects/$id/repository/files/${item.path.urlencode}/raw?ref=master', // TODO:
|
||||
url: item.type == 'tree'
|
||||
? '/gitlab/projects/$id/tree/$ref?path=${item.path.urlencode}'
|
||||
: item.type == 'blob'
|
||||
? '/gitlab/projects/$id/blob/$ref?path=${item.path.urlencode}'
|
||||
: '',
|
||||
),
|
||||
return createObjectTreeItem(
|
||||
type: item.type,
|
||||
name: item.name,
|
||||
downloadUrl:
|
||||
'${auth.activeAccount!.domain}/api/v4/projects/$id/repository/files/${item.path.urlencode}/raw?ref=master', // TODO:
|
||||
url: item.type == 'tree'
|
||||
? '/gitlab/projects/$id/tree/$ref?path=${item.path.urlencode}'
|
||||
: item.type == 'blob'
|
||||
? '/gitlab/projects/$id/blob/$ref?path=${item.path.urlencode}'
|
||||
: '',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -14,7 +14,6 @@ import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
class RepositoryItem extends StatelessWidget {
|
||||
|
||||
const RepositoryItem({
|
||||
required this.owner,
|
||||
required this.avatarUrl,
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
import 'package:antd_mobile/antd_mobile.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
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;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Text(
|
||||
title!.toUpperCase(),
|
||||
style: TextStyle(color: theme.palette.secondaryText, fontSize: 13),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TableViewItemWidget extends StatelessWidget {
|
||||
const TableViewItemWidget(this.item, {super.key});
|
||||
|
||||
final AntListItem item;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
||||
return LinkWidget(
|
||||
onTap: item.onClick,
|
||||
child: DefaultTextStyle(
|
||||
style: TextStyle(fontSize: 17, color: theme.palette.text),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
child: SizedBox(
|
||||
height: 44,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: (item.prefix == null) ? 12 : 44,
|
||||
child: Center(child: item.prefix),
|
||||
),
|
||||
Expanded(child: item.child),
|
||||
if (item.extra != null) ...[
|
||||
DefaultTextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 17,
|
||||
color: theme.palette.tertiaryText,
|
||||
),
|
||||
child: item.extra!,
|
||||
),
|
||||
const SizedBox(width: 6)
|
||||
],
|
||||
if (item.onClick != null)
|
||||
Icon(Ionicons.chevron_forward,
|
||||
size: 20, color: theme.palette.tertiaryText)
|
||||
else
|
||||
const SizedBox(width: 2),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user