Skip to content

Commit 00b2c1c

Browse files
Tomasz KądziołkaTomasz Kądziołka
authored andcommitted
Corrected snippet code view on details
1 parent 7c36a9a commit 00b2c1c

File tree

6 files changed

+117
-7
lines changed

6 files changed

+117
-7
lines changed

app/src/main/java/pl/tkadziolka/snipmeandroid/bridge/Bridge.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ public void setUserReaction(@Nullable UserReaction setterArg) {
176176
this.userReaction = setterArg;
177177
}
178178

179+
private @Nullable Boolean isPrivate;
180+
public @Nullable Boolean getIsPrivate() { return isPrivate; }
181+
public void setIsPrivate(@Nullable Boolean setterArg) {
182+
this.isPrivate = setterArg;
183+
}
184+
179185
private @Nullable Boolean isLiked;
180186
public @Nullable Boolean getIsLiked() { return isLiked; }
181187
public void setIsLiked(@Nullable Boolean setterArg) {
@@ -240,6 +246,11 @@ public static final class Builder {
240246
this.userReaction = setterArg;
241247
return this;
242248
}
249+
private @Nullable Boolean isPrivate;
250+
public @NonNull Builder setIsPrivate(@Nullable Boolean setterArg) {
251+
this.isPrivate = setterArg;
252+
return this;
253+
}
243254
private @Nullable Boolean isLiked;
244255
public @NonNull Builder setIsLiked(@Nullable Boolean setterArg) {
245256
this.isLiked = setterArg;
@@ -266,6 +277,7 @@ public static final class Builder {
266277
pigeonReturn.setTimeAgo(timeAgo);
267278
pigeonReturn.setVoteResult(voteResult);
268279
pigeonReturn.setUserReaction(userReaction);
280+
pigeonReturn.setIsPrivate(isPrivate);
269281
pigeonReturn.setIsLiked(isLiked);
270282
pigeonReturn.setIsDisliked(isDisliked);
271283
pigeonReturn.setIsSaved(isSaved);
@@ -283,6 +295,7 @@ public static final class Builder {
283295
toMapResult.put("timeAgo", timeAgo);
284296
toMapResult.put("voteResult", voteResult);
285297
toMapResult.put("userReaction", userReaction == null ? null : userReaction.index);
298+
toMapResult.put("isPrivate", isPrivate);
286299
toMapResult.put("isLiked", isLiked);
287300
toMapResult.put("isDisliked", isDisliked);
288301
toMapResult.put("isSaved", isSaved);
@@ -308,6 +321,8 @@ public static final class Builder {
308321
pigeonResult.setVoteResult((voteResult == null) ? null : ((voteResult instanceof Integer) ? (Integer)voteResult : (Long)voteResult));
309322
Object userReaction = map.get("userReaction");
310323
pigeonResult.setUserReaction(userReaction == null ? null : UserReaction.values()[(int)userReaction]);
324+
Object isPrivate = map.get("isPrivate");
325+
pigeonResult.setIsPrivate((Boolean)isPrivate);
311326
Object isLiked = map.get("isLiked");
312327
pigeonResult.setIsLiked((Boolean)isLiked);
313328
Object isDisliked = map.get("isDisliked");

app/src/main/java/pl/tkadziolka/snipmeandroid/domain/snippets/Snippet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ data class Snippet(
2323
title = "",
2424
code = SnippetCode("", SpannableString("")),
2525
language = SnippetLanguage("", SnippetLanguageType.UNKNOWN),
26-
visibility = SnippetVisibility.PUBLIC,
26+
visibility = SnippetVisibility.PRIVATE,
2727
isOwner = false,
2828
owner = Owner(0, ""),
2929
modifiedAt = Date(),

flutter_module/bridge/main_model.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Snippet {
1212
String? timeAgo;
1313
int? voteResult;
1414
UserReaction? userReaction;
15+
bool? isPrivate;
1516
bool? isLiked;
1617
bool? isDisliked;
1718
bool? isSaved;

flutter_module/lib/model/main_model.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class Snippet {
9090
this.timeAgo,
9191
this.voteResult,
9292
this.userReaction,
93+
this.isPrivate,
9394
this.isLiked,
9495
this.isDisliked,
9596
this.isSaved,
@@ -104,6 +105,7 @@ class Snippet {
104105
String? timeAgo;
105106
int? voteResult;
106107
UserReaction? userReaction;
108+
bool? isPrivate;
107109
bool? isLiked;
108110
bool? isDisliked;
109111
bool? isSaved;
@@ -119,6 +121,7 @@ class Snippet {
119121
pigeonMap['timeAgo'] = timeAgo;
120122
pigeonMap['voteResult'] = voteResult;
121123
pigeonMap['userReaction'] = userReaction?.index;
124+
pigeonMap['isPrivate'] = isPrivate;
122125
pigeonMap['isLiked'] = isLiked;
123126
pigeonMap['isDisliked'] = isDisliked;
124127
pigeonMap['isSaved'] = isSaved;
@@ -145,6 +148,7 @@ class Snippet {
145148
userReaction: pigeonMap['userReaction'] != null
146149
? UserReaction.values[pigeonMap['userReaction']! as int]
147150
: null,
151+
isPrivate: pigeonMap['isPrivate'] as bool?,
148152
isLiked: pigeonMap['isLiked'] as bool?,
149153
isDisliked: pigeonMap['isDisliked'] as bool?,
150154
isSaved: pigeonMap['isSaved'] as bool?,

flutter_module/lib/presentation/screens/details_screen.dart

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class DetailsScreen extends NamedScreen {
1818
static String name = 'details';
1919

2020
final DetailsNavigator navigator;
21-
final DetailsModel
21+
22+
// final DetailsModel
2223

2324
@override
2425
Widget builder(BuildContext context, GoRouterState state) {
@@ -52,6 +53,9 @@ class _DetailsPage extends HookWidget {
5253
onPressed: navigator.back,
5354
color: Colors.black,
5455
),
56+
actions: snippet?.isPrivate == true
57+
? [const PaddingStyles.regular(Icon(Icons.visibility_off_outlined))]
58+
: null,
5559
),
5660
body: Column(
5761
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -60,8 +64,19 @@ class _DetailsPage extends HookWidget {
6064
Expanded(
6165
child: ColoredBox(
6266
color: ColorStyles.codeBackground(),
63-
child: PaddingStyles.regular(
64-
CodeTextView(code: snippet!.code!.raw!),
67+
child: NotificationListener<OverscrollIndicatorNotification>(
68+
onNotification: (overScroll) {
69+
overScroll.disallowIndicator();
70+
return true;
71+
},
72+
child: SingleChildScrollView(
73+
padding: const EdgeInsets.all(Dimens.l),
74+
physics: const ClampingScrollPhysics(),
75+
child: CodeTextView(
76+
code: snippet!.code!.raw!,
77+
tokens: snippet?.code?.tokens,
78+
),
79+
),
6580
),
6681
),
6782
),

flutter_module/lib/utils/mock/mocks.dart

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,87 @@ class Mocks {
1111
userReaction: UserReaction.like,
1212
isLiked: true,
1313
isDisliked: false,
14+
isPrivate: true,
1415
language: SnippetLanguage(
15-
raw: 'Kotlin',
16-
type: SnippetLanguageType.kotlin,
16+
raw: 'Python',
17+
type: SnippetLanguageType.python,
1718
),
1819
code: SnippetCode(
19-
raw: 'class NewClass { }',
20+
raw: '''
21+
#!/usr/bin/env python
22+
"""Test file for Python syntax highlighting in editors / IDEs.
23+
Meant to cover a wide range of different types of statements and expressions.
24+
Not necessarily sensical or comprehensive (assume that if one exception is
25+
highlighted that all are, for instance).
26+
Extraneous trailing whitespace can't be tested because of svn pre-commit hook
27+
checks for such things.
28+
"""
29+
# Comment
30+
# OPTIONAL: XXX catch your attention
31+
# TODO(me): next big thing
32+
# FIXME: this does not work
33+
34+
# Statements
35+
from __future__ import with_statement # Import
36+
from sys import path as thing
37+
38+
print(thing)
39+
40+
assert True # keyword
41+
42+
43+
def foo(): # function definition
44+
return []
45+
46+
47+
class Bar(object): # Class definition
48+
def __enter__(self):
49+
pass
50+
51+
def __exit__(self, *args):
52+
pass
53+
54+
foo() # UNCOLOURED: function call
55+
while False: # 'while'
56+
continue
57+
for x in foo(): # 'for'
58+
break
59+
with Bar() as stuff:
60+
pass
61+
if False:
62+
pass # 'if'
63+
elif False:
64+
pass
65+
else:
66+
pass
67+
68+
# Constants
69+
'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted
70+
"double-quote"
71+
"""triple double-quote"""
72+
r'raw'
73+
ur'unicode raw'
74+
'escape\n'
75+
'\04' # octal
76+
'\xFF' # hex
77+
'\u1111' # unicode character
78+
1 # Integral
79+
1L
80+
1.0 # Float
81+
.1
82+
1+2j # Complex
83+
84+
# Expressions
85+
1 and 2 or 3 # Boolean operators
86+
2 < 3 # UNCOLOURED: comparison operators
87+
spam = 42 # UNCOLOURED: assignment
88+
2 + 3 # UNCOLOURED: number operators
89+
[] # UNCOLOURED: list
90+
{} # UNCOLOURED: dict
91+
(1,) # UNCOLOURED: tuple
92+
all # Built-in functions
93+
GeneratorExit # Exceptions
94+
''',
2095
tokens: [
2196
SyntaxToken(
2297
start: 0,

0 commit comments

Comments
 (0)