Skip to content

Commit 7c38ee9

Browse files
committed
Changed properties of snippet
1 parent 655e44a commit 7c38ee9

File tree

7 files changed

+47
-72
lines changed

7 files changed

+47
-72
lines changed

app/src/main/java/dev/snipme/snipmeapp/channel/DataModel.g.kt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,8 @@ data class Snippet (
166166
val code: SnippetCode? = null,
167167
val language: SnippetLanguage? = null,
168168
val timeAgo: String? = null,
169-
val voteResult: Long? = null,
170-
val isPrivate: Boolean? = null,
171-
val isFavorite: Boolean? = null,
172-
val isSaved: Boolean? = null,
173-
val isToDelete: Boolean? = null
169+
val isHidden: Boolean? = null,
170+
val isFavorite: Boolean? = null
174171
)
175172
{
176173
companion object {
@@ -180,12 +177,9 @@ data class Snippet (
180177
val code = pigeonVar_list[2] as SnippetCode?
181178
val language = pigeonVar_list[3] as SnippetLanguage?
182179
val timeAgo = pigeonVar_list[4] as String?
183-
val voteResult = pigeonVar_list[5] as Long?
184-
val isPrivate = pigeonVar_list[6] as Boolean?
185-
val isFavorite = pigeonVar_list[7] as Boolean?
186-
val isSaved = pigeonVar_list[8] as Boolean?
187-
val isToDelete = pigeonVar_list[9] as Boolean?
188-
return Snippet(uuid, title, code, language, timeAgo, voteResult, isPrivate, isFavorite, isSaved, isToDelete)
180+
val isHidden = pigeonVar_list[5] as Boolean?
181+
val isFavorite = pigeonVar_list[6] as Boolean?
182+
return Snippet(uuid, title, code, language, timeAgo, isHidden, isFavorite)
189183
}
190184
}
191185
fun toList(): List<Any?> {
@@ -195,11 +189,8 @@ data class Snippet (
195189
code,
196190
language,
197191
timeAgo,
198-
voteResult,
199-
isPrivate,
192+
isHidden,
200193
isFavorite,
201-
isSaved,
202-
isToDelete,
203194
)
204195
}
205196
}

flutter_module/channel/contract.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ class Snippet {
1616
SnippetCode? code;
1717
SnippetLanguage? language;
1818
String? timeAgo;
19-
int? voteResult;
20-
bool? isPrivate;
19+
bool? isHidden;
2120
bool? isFavorite;
22-
bool? isSaved;
23-
bool? isToDelete;
2421
}
2522

2623
class SnippetCode {

flutter_module/lib/generated/data_model.g.dart

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,8 @@ class Snippet {
9999
this.code,
100100
this.language,
101101
this.timeAgo,
102-
this.voteResult,
103-
this.isPrivate,
102+
this.isHidden,
104103
this.isFavorite,
105-
this.isSaved,
106-
this.isToDelete,
107104
});
108105

109106
String? uuid;
@@ -116,28 +113,19 @@ class Snippet {
116113

117114
String? timeAgo;
118115

119-
int? voteResult;
120-
121-
bool? isPrivate;
116+
bool? isHidden;
122117

123118
bool? isFavorite;
124119

125-
bool? isSaved;
126-
127-
bool? isToDelete;
128-
129120
Object encode() {
130121
return <Object?>[
131122
uuid,
132123
title,
133124
code,
134125
language,
135126
timeAgo,
136-
voteResult,
137-
isPrivate,
127+
isHidden,
138128
isFavorite,
139-
isSaved,
140-
isToDelete,
141129
];
142130
}
143131

@@ -149,11 +137,8 @@ class Snippet {
149137
code: result[2] as SnippetCode?,
150138
language: result[3] as SnippetLanguage?,
151139
timeAgo: result[4] as String?,
152-
voteResult: result[5] as int?,
153-
isPrivate: result[6] as bool?,
154-
isFavorite: result[7] as bool?,
155-
isSaved: result[8] as bool?,
156-
isToDelete: result[9] as bool?,
140+
isHidden: result[5] as bool?,
141+
isFavorite: result[6] as bool?,
157142
);
158143
}
159144
}

flutter_module/lib/presentation/screens/details_screen.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class _DetailsPage extends HookConsumerWidget {
105105
onPressed: navigator.back,
106106
color: Colors.black,
107107
),
108-
actions: stateNotification.data?.isPrivate == true
109-
? [const PaddingStyles.regular(Icon(Icons.lock_outlined))]
108+
actions: stateNotification.data?.isHidden == true
109+
? [const PaddingStyles.regular(Icon(Icons.visibility_off_outlined))]
110110
: null,
111111
),
112112
body: ViewStateWrapper<Snippet>(

flutter_module/lib/presentation/widgets/snippet_action_bar.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class SnippetActionBar extends StatelessWidget {
1111
this.onSaveTap,
1212
this.onCopyTap,
1313
this.onShareTap,
14-
// TODO Add archive action
14+
this.onHideTap,
1515
this.onDeleteTap,
1616
super.key,
1717
});
@@ -21,6 +21,7 @@ class SnippetActionBar extends StatelessWidget {
2121
final GestureTapCallback? onSaveTap;
2222
final GestureTapCallback? onCopyTap;
2323
final GestureTapCallback? onShareTap;
24+
final GestureTapCallback? onHideTap;
2425
final GestureTapCallback? onDeleteTap;
2526

2627
@override
@@ -51,8 +52,13 @@ class SnippetActionBar extends StatelessWidget {
5152
),
5253
const SizedBox(width: Dimens.l),
5354
StateIcon(
54-
onTap: snippet.isToDelete == true ? onDeleteTap : null,
55-
active: snippet.isToDelete == true ? null : false,
55+
icon: Icons.visibility_off_outlined,
56+
onTap: onHideTap,
57+
),
58+
const SizedBox(width: Dimens.l),
59+
StateIcon(
60+
onTap: onDeleteTap,
61+
active: true,
5662
activeColor: Colors.redAccent,
5763
icon: Icons.delete_outline_outlined,
5864
),

flutter_module/lib/presentation/widgets/snippet_details_bar.dart

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,29 @@ class SnippetDetailsBar extends StatelessWidget {
1414

1515
@override
1616
Widget build(BuildContext context) {
17-
return Row(
18-
children: [
19-
Expanded(
20-
child: Column(
21-
mainAxisSize: MainAxisSize.min,
22-
crossAxisAlignment: CrossAxisAlignment.stretch,
23-
children: [
24-
TextStyles.regular(snippet.language?.raw ?? "Unknown language"),
25-
const SizedBox(height: Dimens.m),
26-
// TODO FIX
27-
const TextStyles.secondary("!!!Show archive status!!!"),
28-
const SizedBox(height: Dimens.s),
29-
TextStyles.helper(snippet.timeAgo ?? "")
30-
],
31-
),
17+
final visibilityIcon = snippet.isHidden == true
18+
? Icons.visibility_off_outlined
19+
: Icons.visibility_outlined;
20+
21+
final visibilityText = snippet.isHidden == true ? "Hidden" : "Visible";
22+
23+
return Row(children: [
24+
Expanded(
25+
child: Column(
26+
mainAxisSize: MainAxisSize.min,
27+
crossAxisAlignment: CrossAxisAlignment.stretch,
28+
children: [
29+
TextStyles.regular(snippet.language?.raw ?? "Unknown language"),
30+
const SizedBox(height: Dimens.m),
31+
TextStyles.secondary(visibilityText),
32+
const SizedBox(height: Dimens.s),
33+
TextStyles.helper(snippet.timeAgo ?? "")
34+
],
3235
),
33-
SurfaceStyles.rateBox(
34-
TextStyles.title(
35-
TextSpan(
36-
children: [
37-
WidgetSpan(child: Icon(Icons.visibility)),
38-
]
39-
).text!
40-
),
41-
)
42-
],
43-
);
36+
),
37+
SurfaceStyles.rateBox(TextStyles.title(
38+
TextSpan(children: [WidgetSpan(child: Icon(visibilityIcon))]).text!,
39+
)),
40+
]);
4441
}
4542
}

flutter_module/lib/utils/mock/mocks.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ class Mocks {
66
uuid: '',
77
title: 'New snippet',
88
timeAgo: '2 days ago',
9-
voteResult: 32,
109
isFavorite: false,
11-
isPrivate: true,
10+
isHidden: true,
1211
language: SnippetLanguage(
1312
raw: 'Python',
1413
type: SnippetLanguageType.python,

0 commit comments

Comments
 (0)