From 575d630c5f52483915152cf86a9904fabf76df40 Mon Sep 17 00:00:00 2001 From: unweek Date: Thu, 2 Jan 2020 22:24:40 +0100 Subject: [PATCH 1/8] feat: Emojis in emoji button --- lib/widgets/input/input_bar.dart | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/widgets/input/input_bar.dart b/lib/widgets/input/input_bar.dart index 5448d02..046b47e 100644 --- a/lib/widgets/input/input_bar.dart +++ b/lib/widgets/input/input_bar.dart @@ -368,6 +368,7 @@ class InputBarWidgetState extends State { } Widget _drawButtons() { + List lennies = ['( ͡° ͜ʖ ͡°)','( ͡° ʖ̯ ͡°)','( ͡º ͜ʖ͡º)','( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)','(╥﹏╥)','(╯︵╰,)','(ʘ‿ʘ)','(。◕‿‿◕。)','(⇀‸↼‶)','(òóˇ)','(✌ ゚ ∀ ゚)☞','ʕ•ᴥ•ʔ','ᶘᵒᴥᵒᶅ','(⌒(oo)⌒)','ᄽὁȍ ̪ őὀᄿ','( ͡€ ͜ʖ ͡€)','( ͡° ͜ʖ ͡°)','( ͡° ͜ʖ ͡°)ノ⌐■-■','(⌐ ͡■ ͜ʖ ͡■)','¯\\\\\\_(ツ)\\_/¯','(ꖘ⏏ꖘ)','(╯°□°)╯︵ ┻━┻','( ͡~ ͜ʖ ͡°)','( ಠ_ಠ)','(・へ・)','(ง✿﹏✿)ง','(づ•﹏•)づ','乁(♥ ʖ̯♥)ㄏ','|૦ઁ෴૦ઁ','乁(⫑ᴥ⫒)ㄏ','(ꖘ‸ꖘ)','(✿ ͟ʖ✿)','(งⱺ ͟ل͜ⱺ)ง','( ̄෴ ̄)','ヽ( ͠°෴ °)','└[⚆ᴥ⚆]┘','ヽ(☼ᨓ☼)ノ','XD','(ⴲ﹏ⴲ)','(ಠ‸ಠ)','(ง ͠° ͟ل͜ ͡°)ง','( ಠ_ಠ)','(-‸ლ)','( ͡° ͜ʖ ͡° )つ──☆*:・゚','(╭☞σ ͜ʖσ)╭☞"']; if (showMarkdownBar || hasExternalInput) { return SingleChildScrollView( scrollDirection: Axis.horizontal, @@ -386,7 +387,24 @@ class InputBarWidgetState extends State { child: _drawIconRound( icon: Icons.mood, tooltip: "Emotikony", - onTap: () => {}, // TODO: dodac ekran z lennymi + onTap: () => { + showDialog( + context: context, + builder: (context) => GreatDialogWidget( + child: ListView.builder( + itemCount: lennies.length, + padding: const EdgeInsets.all(16.0), // TODO: lepiej dopasowany EdgeInsert + itemBuilder: (context, i) { + if (i.isOdd) return Divider(); + final index = i ~/ 2; + return ListTile( + title: Text(lennies[index]) + ); + } + ), + ) + ) + }, ), ), _drawIconRound( From ebc208935aead4c595a8eb4fe9b8a463448d221e Mon Sep 17 00:00:00 2001 From: unweek Date: Fri, 3 Jan 2020 09:51:46 +0100 Subject: [PATCH 2/8] feat: Working emoji dialog --- lib/widgets/input/input_bar.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/widgets/input/input_bar.dart b/lib/widgets/input/input_bar.dart index 046b47e..eea89a8 100644 --- a/lib/widgets/input/input_bar.dart +++ b/lib/widgets/input/input_bar.dart @@ -398,7 +398,13 @@ class InputBarWidgetState extends State { if (i.isOdd) return Divider(); final index = i ~/ 2; return ListTile( - title: Text(lennies[index]) + title: GestureDetector( + child: Text(lennies[index]), + onTap: () { + Navigator.pop(context); + textController.text += lennies[index]; + }, + ) ); } ), From c7971ef84249c3b352d1334f074f646d88a82fb0 Mon Sep 17 00:00:00 2001 From: unweek Date: Sat, 4 Jan 2020 01:12:21 +0100 Subject: [PATCH 3/8] feat: Comment voters list --- lib/api/resources/entries.dart | 8 +++++++ lib/model/entry_comment_model.dart | 8 +++++++ lib/widgets/entry/entry_comment.dart | 32 ++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/lib/api/resources/entries.dart b/lib/api/resources/entries.dart index 9fe8dce..25cceb1 100644 --- a/lib/api/resources/entries.dart +++ b/lib/api/resources/entries.dart @@ -126,4 +126,12 @@ class EntriesApi extends ApiResource { print(voteCount); return int.parse(voteCount["vote_count"]); } + + Future> getCommentUpVoters(int id) async { + var items = + await client.request('entries', 'commentupvoters', api: [id.toString()]); + print(items); + var voters = client.deserializeList(VoterResponse.serializer, items); + return voters.map((e) => Voter.fromResponse(response: e)).toList(); + } } diff --git a/lib/model/entry_comment_model.dart b/lib/model/entry_comment_model.dart index 2c0574c..a2acc74 100644 --- a/lib/model/entry_comment_model.dart +++ b/lib/model/entry_comment_model.dart @@ -11,6 +11,7 @@ class EntryCommentModel extends ChangeNotifier { Embed _embed; bool _isVoted; bool _isExpanded; + List _upvoters; String _violationUrl; int get id => _id; @@ -23,6 +24,8 @@ class EntryCommentModel extends ChangeNotifier { bool get isVoted => _isVoted; String get violationUrl => _violationUrl; + List get upvoters => _upvoters.reversed.toList(); + void expand() { _isExpanded = true; notifyListeners(); @@ -45,6 +48,11 @@ class EntryCommentModel extends ChangeNotifier { _body = "[Komentarz usunięty]"; notifyListeners(); } + + Future loadUpVoters() async { + _upvoters = await api.entries.getCommentUpVoters(_id); + notifyListeners(); + } Future toggleVote() async { if (!_isVoted) { diff --git a/lib/widgets/entry/entry_comment.dart b/lib/widgets/entry/entry_comment.dart index c3b9311..404cdcf 100644 --- a/lib/widgets/entry/entry_comment.dart +++ b/lib/widgets/entry/entry_comment.dart @@ -167,13 +167,10 @@ class _EntryCommentWidgetState extends State { isComment: true, count: model.voteCount, onClicked: () => model.toggleVote(), - onLongClicked: () => showDialog( - context: context, - builder: (_) => GreatDialogWidget( - child: Text( - "Niezaimplementowane"), //TODO: implement voters list - ), - ), + onLongClicked: () { + model.loadUpVoters(); + _showVotersDialog(context, model.upvoters); + } ), ), ], @@ -313,4 +310,25 @@ class _EntryCommentWidgetState extends State { if (i > 999) return 30.0; return 0.0; } + + void _showVotersDialog(BuildContext context, List voters) { + showDialog( + context: context, + builder: (context) => GreatDialogWidget( + padding: EdgeInsets.zero, + child: ListView.builder( + shrinkWrap: true, + itemCount: voters.length, + itemBuilder: (context, index) { + return AuthorWidget( + author: voters[index].author, + date: voters[index].date, + fontSize: 14.0, + avatarBorderColor: Theme.of(context).dialogBackgroundColor, + ); + }, + ), + ), + ); + } } From 5906bd2c185bfaac7808874c02a09472ea4a12bc Mon Sep 17 00:00:00 2001 From: unweek Date: Sat, 4 Jan 2020 11:18:22 +0100 Subject: [PATCH 4/8] feat: System dark theme --- lib/app.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/app.dart b/lib/app.dart index 47b4646..0900bde 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -39,6 +39,7 @@ class OwmApp extends StatelessWidget { theme: settings.useDarkTheme ? Themes.darkTheme(accentColor: settings.accentColor) : Themes.lightTheme(accentColor: settings.accentColor), + darkTheme: Themes.darkTheme(accentColor: settings.accentColor), // TODO: zrobić, żeby zmana tła działała na sestemowym ciemnym routes: { '/': (context) => MainScreen(), }, From 58b9caf0267f9df0fd071922f30fe67c6d34010e Mon Sep 17 00:00:00 2001 From: unweek Date: Sat, 4 Jan 2020 14:18:23 +0100 Subject: [PATCH 5/8] feat: System dark mode settings --- lib/app.dart | 4 +++- lib/screens/settings/appearance.dart | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/app.dart b/lib/app.dart index 0900bde..a019a77 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -39,7 +39,9 @@ class OwmApp extends StatelessWidget { theme: settings.useDarkTheme ? Themes.darkTheme(accentColor: settings.accentColor) : Themes.lightTheme(accentColor: settings.accentColor), - darkTheme: Themes.darkTheme(accentColor: settings.accentColor), // TODO: zrobić, żeby zmana tła działała na sestemowym ciemnym + darkTheme: settings.autoDarkTheme == 3 // TODO: zrobić, żeby zmana tła działała na systemowym ciemnym + ? Themes.darkTheme(accentColor: settings.accentColor) + : null, routes: { '/': (context) => MainScreen(), }, diff --git a/lib/screens/settings/appearance.dart b/lib/screens/settings/appearance.dart index e5ef367..39bcae5 100644 --- a/lib/screens/settings/appearance.dart +++ b/lib/screens/settings/appearance.dart @@ -107,6 +107,15 @@ class AppearanceSettingScreen extends StatelessWidget { value: 2, title: Text("W określonych godzinach"), ), + RadioListTile( + groupValue: settings.autoDarkTheme, + onChanged: (value) { + settings.autoDarkTheme = value; + Navigator.of(context).pop(); + }, + value: 3, + title: Text("Systemowo"), + ), ], ); }, From 91b5c8017406bbc74bf23571c3f25cd729b0b463 Mon Sep 17 00:00:00 2001 From: unweek Date: Sat, 4 Jan 2020 23:19:48 +0100 Subject: [PATCH 6/8] feat: Pm button in user dialog --- lib/widgets/user_dialog.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/widgets/user_dialog.dart b/lib/widgets/user_dialog.dart index 962c2c4..5302da0 100644 --- a/lib/widgets/user_dialog.dart +++ b/lib/widgets/user_dialog.dart @@ -3,6 +3,7 @@ import 'package:owmflutter/model/model.dart'; import 'package:owmflutter/model/profile_model.dart'; import 'package:owmflutter/models/author.dart'; import 'package:owmflutter/screens/profile.dart'; +import 'package:owmflutter/screens/screens.dart'; import 'package:owmflutter/utils/utils.dart'; import 'package:owmflutter/widgets/widgets.dart'; import 'package:provider/provider.dart'; @@ -175,7 +176,13 @@ class _UserDialogWidgetState extends State _button( text: "Napisz", disable: widget.isAuthor, - onTap: () {}, //TODO: get pm screen + onTap: () { + Navigator.of(context).push( + Utils.getPageTransition( + PmScreen(receiver: widget.author.login) + ) + ); + }, //TODO: get pm screen padding: EdgeInsets.only(left: 6.0), ), ], From f7e3e85f5fb6a74cba1122e7babbd38c9717d64c Mon Sep 17 00:00:00 2001 From: unweek Date: Sat, 11 Jan 2020 15:07:09 +0100 Subject: [PATCH 7/8] feat: User app in entries and comments --- .../entry_comment_response.dart | 3 ++ .../entry_comment_response.g.dart | 45 ++++++++++++---- lib/api/response_models/entry_response.dart | 3 ++ lib/api/response_models/entry_response.g.dart | 53 ++++++++++++++----- lib/model/entry_comment_model.dart | 3 ++ lib/model/entry_model.dart | 4 ++ lib/models/entry.dart | 6 ++- lib/models/entry.g.dart | 45 ++++++++++------ lib/models/entry_comment.dart | 6 ++- lib/models/entry_comment.g.dart | 37 ++++++++----- lib/widgets/author.dart | 4 +- lib/widgets/entry/entry.dart | 1 + lib/widgets/entry/entry_comment.dart | 2 +- 13 files changed, 155 insertions(+), 57 deletions(-) diff --git a/lib/api/response_models/entry_comment_response.dart b/lib/api/response_models/entry_comment_response.dart index d59e152..a6f8bf5 100644 --- a/lib/api/response_models/entry_comment_response.dart +++ b/lib/api/response_models/entry_comment_response.dart @@ -30,6 +30,9 @@ abstract class EntryCommentResponse @BuiltValueField(wireName: "violation_url") String get violationUrl; + @nullable + String get app; + EntryCommentResponse._(); static Serializer get serializer => _$entryCommentResponseSerializer; diff --git a/lib/api/response_models/entry_comment_response.g.dart b/lib/api/response_models/entry_comment_response.g.dart index e4022ee..95b0df4 100644 --- a/lib/api/response_models/entry_comment_response.g.dart +++ b/lib/api/response_models/entry_comment_response.g.dart @@ -59,6 +59,12 @@ class _$EntryCommentResponseSerializer ..add(serializers.serialize(object.violationUrl, specifiedType: const FullType(String))); } + if (object.app != null) { + result + ..add('app') + ..add(serializers.serialize(object.app, + specifiedType: const FullType(String))); + } return result; } @@ -106,6 +112,10 @@ class _$EntryCommentResponseSerializer result.violationUrl = serializers.deserialize(value, specifiedType: const FullType(String)) as String; break; + case 'app': + result.app = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; } } @@ -130,6 +140,8 @@ class _$EntryCommentResponse extends EntryCommentResponse { final EmbedResponse embed; @override final String violationUrl; + @override + final String app; factory _$EntryCommentResponse( [void Function(EntryCommentResponseBuilder) updates]) => @@ -143,7 +155,8 @@ class _$EntryCommentResponse extends EntryCommentResponse { this.voteCount, this.author, this.embed, - this.violationUrl}) + this.violationUrl, + this.app}) : super._() { if (id == null) { throw new BuiltValueNullFieldError('EntryCommentResponse', 'id'); @@ -179,7 +192,8 @@ class _$EntryCommentResponse extends EntryCommentResponse { voteCount == other.voteCount && author == other.author && embed == other.embed && - violationUrl == other.violationUrl; + violationUrl == other.violationUrl && + app == other.app; } @override @@ -189,13 +203,15 @@ class _$EntryCommentResponse extends EntryCommentResponse { $jc( $jc( $jc( - $jc($jc($jc(0, id.hashCode), date.hashCode), - body.hashCode), - userVote.hashCode), - voteCount.hashCode), - author.hashCode), - embed.hashCode), - violationUrl.hashCode)); + $jc( + $jc($jc($jc(0, id.hashCode), date.hashCode), + body.hashCode), + userVote.hashCode), + voteCount.hashCode), + author.hashCode), + embed.hashCode), + violationUrl.hashCode), + app.hashCode)); } @override @@ -208,7 +224,8 @@ class _$EntryCommentResponse extends EntryCommentResponse { ..add('voteCount', voteCount) ..add('author', author) ..add('embed', embed) - ..add('violationUrl', violationUrl)) + ..add('violationUrl', violationUrl) + ..add('app', app)) .toString(); } } @@ -251,6 +268,10 @@ class EntryCommentResponseBuilder String get violationUrl => _$this._violationUrl; set violationUrl(String violationUrl) => _$this._violationUrl = violationUrl; + String _app; + String get app => _$this._app; + set app(String app) => _$this._app = app; + EntryCommentResponseBuilder(); EntryCommentResponseBuilder get _$this { @@ -263,6 +284,7 @@ class EntryCommentResponseBuilder _author = _$v.author?.toBuilder(); _embed = _$v.embed?.toBuilder(); _violationUrl = _$v.violationUrl; + _app = _$v.app; _$v = null; } return this; @@ -294,7 +316,8 @@ class EntryCommentResponseBuilder voteCount: voteCount, author: author.build(), embed: _embed?.build(), - violationUrl: violationUrl); + violationUrl: violationUrl, + app: app); } catch (_) { String _$failedField; try { diff --git a/lib/api/response_models/entry_response.dart b/lib/api/response_models/entry_response.dart index 65989d7..6130ad6 100644 --- a/lib/api/response_models/entry_response.dart +++ b/lib/api/response_models/entry_response.dart @@ -40,6 +40,9 @@ abstract class EntryResponse @BuiltValueField(wireName: "violation_url") String get violationUrl; + @nullable + String get app; + EntryResponse._(); static Serializer get serializer => _$entryResponseSerializer; } diff --git a/lib/api/response_models/entry_response.g.dart b/lib/api/response_models/entry_response.g.dart index 7c77e77..d2f10b4 100644 --- a/lib/api/response_models/entry_response.g.dart +++ b/lib/api/response_models/entry_response.g.dart @@ -73,6 +73,12 @@ class _$EntryResponseSerializer implements StructuredSerializer { ..add(serializers.serialize(object.violationUrl, specifiedType: const FullType(String))); } + if (object.app != null) { + result + ..add('app') + ..add(serializers.serialize(object.app, + specifiedType: const FullType(String))); + } return result; } @@ -134,6 +140,10 @@ class _$EntryResponseSerializer implements StructuredSerializer { result.violationUrl = serializers.deserialize(value, specifiedType: const FullType(String)) as String; break; + case 'app': + result.app = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; } } @@ -164,6 +174,8 @@ class _$EntryResponse extends EntryResponse { final EmbedResponse embed; @override final String violationUrl; + @override + final String app; factory _$EntryResponse([void Function(EntryResponseBuilder) updates]) => (new EntryResponseBuilder()..update(updates)).build(); @@ -179,7 +191,8 @@ class _$EntryResponse extends EntryResponse { this.commentsCount, this.author, this.embed, - this.violationUrl}) + this.violationUrl, + this.app}) : super._() { if (id == null) { throw new BuiltValueNullFieldError('EntryResponse', 'id'); @@ -216,7 +229,8 @@ class _$EntryResponse extends EntryResponse { commentsCount == other.commentsCount && author == other.author && embed == other.embed && - violationUrl == other.violationUrl; + violationUrl == other.violationUrl && + app == other.app; } @override @@ -229,16 +243,20 @@ class _$EntryResponse extends EntryResponse { $jc( $jc( $jc( - $jc($jc($jc(0, id.hashCode), date.hashCode), - userVote.hashCode), - comments.hashCode), - body.hashCode), - favorite.hashCode), - voteCount.hashCode), - commentsCount.hashCode), - author.hashCode), - embed.hashCode), - violationUrl.hashCode)); + $jc( + $jc( + $jc($jc(0, id.hashCode), + date.hashCode), + userVote.hashCode), + comments.hashCode), + body.hashCode), + favorite.hashCode), + voteCount.hashCode), + commentsCount.hashCode), + author.hashCode), + embed.hashCode), + violationUrl.hashCode), + app.hashCode)); } @override @@ -254,7 +272,8 @@ class _$EntryResponse extends EntryResponse { ..add('commentsCount', commentsCount) ..add('author', author) ..add('embed', embed) - ..add('violationUrl', violationUrl)) + ..add('violationUrl', violationUrl) + ..add('app', app)) .toString(); } } @@ -311,6 +330,10 @@ class EntryResponseBuilder String get violationUrl => _$this._violationUrl; set violationUrl(String violationUrl) => _$this._violationUrl = violationUrl; + String _app; + String get app => _$this._app; + set app(String app) => _$this._app = app; + EntryResponseBuilder(); EntryResponseBuilder get _$this { @@ -326,6 +349,7 @@ class EntryResponseBuilder _author = _$v.author?.toBuilder(); _embed = _$v.embed?.toBuilder(); _violationUrl = _$v.violationUrl; + _app = _$v.app; _$v = null; } return this; @@ -360,7 +384,8 @@ class EntryResponseBuilder commentsCount: commentsCount, author: author.build(), embed: _embed?.build(), - violationUrl: violationUrl); + violationUrl: violationUrl, + app: app); } catch (_) { String _$failedField; try { diff --git a/lib/model/entry_comment_model.dart b/lib/model/entry_comment_model.dart index a2acc74..eeb4f12 100644 --- a/lib/model/entry_comment_model.dart +++ b/lib/model/entry_comment_model.dart @@ -13,6 +13,7 @@ class EntryCommentModel extends ChangeNotifier { bool _isExpanded; List _upvoters; String _violationUrl; + String _app; int get id => _id; String get body => _body; @@ -23,6 +24,7 @@ class EntryCommentModel extends ChangeNotifier { bool get isExpanded => _isExpanded; bool get isVoted => _isVoted; String get violationUrl => _violationUrl; + String get app => _app; List get upvoters => _upvoters.reversed.toList(); @@ -40,6 +42,7 @@ class EntryCommentModel extends ChangeNotifier { _isVoted = comment.isVoted; _isExpanded = comment.isExpanded; _violationUrl = comment.violationUrl; + _app = comment.app; notifyListeners(); } diff --git a/lib/model/entry_model.dart b/lib/model/entry_model.dart index 550c077..86d03bc 100644 --- a/lib/model/entry_model.dart +++ b/lib/model/entry_model.dart @@ -21,6 +21,7 @@ class EntryModel extends InputModel { int _commentsCount; bool _loading = false; String _violationUrl; + String _app; int get id => _id; String get body => _body; @@ -35,6 +36,7 @@ class EntryModel extends InputModel { int get commentsCount => _commentsCount; bool get isLoading => _loading; String get violationUrl => _violationUrl; + String get app => _app; List get comments => _comments; List get upvoters => _upvoters.reversed.toList(); @@ -54,6 +56,8 @@ class EntryModel extends InputModel { _isFavorite = entry.isFavorite; _commentsCount = entry.commentsCount; _violationUrl = entry.violationUrl; + _app = entry.app; + notifyListeners(); } diff --git a/lib/models/entry.dart b/lib/models/entry.dart index 2c1ab48..2b69b36 100644 --- a/lib/models/entry.dart +++ b/lib/models/entry.dart @@ -32,6 +32,9 @@ abstract class Entry implements Built { @nullable String get violationUrl; + @nullable + String get app; + factory Entry.mapFromResponse(EntryResponse response) { return _$Entry._( id: response.id, @@ -51,7 +54,8 @@ abstract class Entry implements Built { embed: (response.embed != null ? Embed.fromResponse(response: response.embed) : null), - violationUrl: response.violationUrl); + violationUrl: response.violationUrl, + app: response.app); } Entry._(); diff --git a/lib/models/entry.g.dart b/lib/models/entry.g.dart index 52dd11c..9eb9714 100644 --- a/lib/models/entry.g.dart +++ b/lib/models/entry.g.dart @@ -31,6 +31,8 @@ class _$Entry extends Entry { final Embed embed; @override final String violationUrl; + @override + final String app; factory _$Entry([void Function(EntryBuilder) updates]) => (new EntryBuilder()..update(updates)).build(); @@ -47,7 +49,8 @@ class _$Entry extends Entry { this.comments, this.author, this.embed, - this.violationUrl}) + this.violationUrl, + this.app}) : super._() { if (id == null) { throw new BuiltValueNullFieldError('Entry', 'id'); @@ -100,7 +103,8 @@ class _$Entry extends Entry { comments == other.comments && author == other.author && embed == other.embed && - violationUrl == other.violationUrl; + violationUrl == other.violationUrl && + app == other.app; } @override @@ -115,18 +119,20 @@ class _$Entry extends Entry { $jc( $jc( $jc( - $jc($jc(0, id.hashCode), - date.hashCode), - body.hashCode), - voteCount.hashCode), - commentsCount.hashCode), - isVoted.hashCode), - isExpanded.hashCode), - isFavorite.hashCode), - comments.hashCode), - author.hashCode), - embed.hashCode), - violationUrl.hashCode)); + $jc( + $jc($jc(0, id.hashCode), + date.hashCode), + body.hashCode), + voteCount.hashCode), + commentsCount.hashCode), + isVoted.hashCode), + isExpanded.hashCode), + isFavorite.hashCode), + comments.hashCode), + author.hashCode), + embed.hashCode), + violationUrl.hashCode), + app.hashCode)); } @override @@ -143,7 +149,8 @@ class _$Entry extends Entry { ..add('comments', comments) ..add('author', author) ..add('embed', embed) - ..add('violationUrl', violationUrl)) + ..add('violationUrl', violationUrl) + ..add('app', app)) .toString(); } } @@ -201,6 +208,10 @@ class EntryBuilder implements Builder { String get violationUrl => _$this._violationUrl; set violationUrl(String violationUrl) => _$this._violationUrl = violationUrl; + String _app; + String get app => _$this._app; + set app(String app) => _$this._app = app; + EntryBuilder(); EntryBuilder get _$this { @@ -217,6 +228,7 @@ class EntryBuilder implements Builder { _author = _$v.author?.toBuilder(); _embed = _$v.embed?.toBuilder(); _violationUrl = _$v.violationUrl; + _app = _$v.app; _$v = null; } return this; @@ -252,7 +264,8 @@ class EntryBuilder implements Builder { comments: comments.build(), author: author.build(), embed: _embed?.build(), - violationUrl: violationUrl); + violationUrl: violationUrl, + app: app); } catch (_) { String _$failedField; try { diff --git a/lib/models/entry_comment.dart b/lib/models/entry_comment.dart index 700bea1..9936252 100644 --- a/lib/models/entry_comment.dart +++ b/lib/models/entry_comment.dart @@ -25,6 +25,9 @@ abstract class EntryComment @nullable String get violationUrl; + @nullable + String get app; + factory EntryComment.mapFromResponse(EntryCommentResponse response) { return _$EntryComment._( id: response.id, @@ -37,7 +40,8 @@ abstract class EntryComment embed: (response.embed != null ? Embed.fromResponse(response: response.embed) : null), - violationUrl: response.violationUrl); + violationUrl: response.violationUrl, + app: response.app); } EntryComment._(); diff --git a/lib/models/entry_comment.g.dart b/lib/models/entry_comment.g.dart index 058a461..9fd2995 100644 --- a/lib/models/entry_comment.g.dart +++ b/lib/models/entry_comment.g.dart @@ -25,6 +25,8 @@ class _$EntryComment extends EntryComment { final Embed embed; @override final String violationUrl; + @override + final String app; factory _$EntryComment([void Function(EntryCommentBuilder) updates]) => (new EntryCommentBuilder()..update(updates)).build(); @@ -38,7 +40,8 @@ class _$EntryComment extends EntryComment { this.isExpanded, this.author, this.embed, - this.violationUrl}) + this.violationUrl, + this.app}) : super._() { if (id == null) { throw new BuiltValueNullFieldError('EntryComment', 'id'); @@ -79,7 +82,8 @@ class _$EntryComment extends EntryComment { isExpanded == other.isExpanded && author == other.author && embed == other.embed && - violationUrl == other.violationUrl; + violationUrl == other.violationUrl && + app == other.app; } @override @@ -90,14 +94,16 @@ class _$EntryComment extends EntryComment { $jc( $jc( $jc( - $jc($jc($jc(0, id.hashCode), date.hashCode), - body.hashCode), - voteCount.hashCode), - isVoted.hashCode), - isExpanded.hashCode), - author.hashCode), - embed.hashCode), - violationUrl.hashCode)); + $jc( + $jc($jc($jc(0, id.hashCode), date.hashCode), + body.hashCode), + voteCount.hashCode), + isVoted.hashCode), + isExpanded.hashCode), + author.hashCode), + embed.hashCode), + violationUrl.hashCode), + app.hashCode)); } @override @@ -111,7 +117,8 @@ class _$EntryComment extends EntryComment { ..add('isExpanded', isExpanded) ..add('author', author) ..add('embed', embed) - ..add('violationUrl', violationUrl)) + ..add('violationUrl', violationUrl) + ..add('app', app)) .toString(); } } @@ -156,6 +163,10 @@ class EntryCommentBuilder String get violationUrl => _$this._violationUrl; set violationUrl(String violationUrl) => _$this._violationUrl = violationUrl; + String _app; + String get app => _$this._app; + set app(String app) => _$this._app = app; + EntryCommentBuilder(); EntryCommentBuilder get _$this { @@ -169,6 +180,7 @@ class EntryCommentBuilder _author = _$v.author?.toBuilder(); _embed = _$v.embed?.toBuilder(); _violationUrl = _$v.violationUrl; + _app = _$v.app; _$v = null; } return this; @@ -201,7 +213,8 @@ class EntryCommentBuilder isExpanded: isExpanded, author: author.build(), embed: _embed?.build(), - violationUrl: violationUrl); + violationUrl: violationUrl, + app: app); } catch (_) { String _$failedField; try { diff --git a/lib/widgets/author.dart b/lib/widgets/author.dart index f840324..db842a9 100644 --- a/lib/widgets/author.dart +++ b/lib/widgets/author.dart @@ -12,6 +12,7 @@ class AuthorWidget extends StatefulWidget { final bool showUserDialog; final bool isAuthor; final Color avatarBorderColor; + final String app; AuthorWidget({ @required this.author, @@ -23,6 +24,7 @@ class AuthorWidget extends StatefulWidget { this.showUserDialog: true, this.isAuthor: false, this.avatarBorderColor, + this.app, }); _AuthorWidgetState createState() => _AuthorWidgetState(); @@ -89,7 +91,7 @@ class _AuthorWidgetState extends State { showFullDate ? Utils.getDateFormat( widget.date, 'dd.MM.yyyy \'o\' HH:mm:ss') - : Utils.getSimpleDate(widget.date), + : Utils.getSimpleDate(widget.date) + (widget.app != null ? " via ${widget.app}" : ""), overflow: TextOverflow.ellipsis, style: TextStyle( height: 1.2, diff --git a/lib/widgets/entry/entry.dart b/lib/widgets/entry/entry.dart index f2d29c6..ff72d07 100644 --- a/lib/widgets/entry/entry.dart +++ b/lib/widgets/entry/entry.dart @@ -37,6 +37,7 @@ class NewEntryWidget extends StatelessWidget { child: AuthorWidget( author: model.author, date: model.date, + app: model.app, fontSize: 15.0, padding: EdgeInsets.only(top: 12.0, right: 4.0), ), diff --git a/lib/widgets/entry/entry_comment.dart b/lib/widgets/entry/entry_comment.dart index 404cdcf..a08a53b 100644 --- a/lib/widgets/entry/entry_comment.dart +++ b/lib/widgets/entry/entry_comment.dart @@ -189,7 +189,7 @@ class _EntryCommentWidgetState extends State { text: showFullDate ? Utils.getDateFormat( model.date, 'dd.MM.yyyy \'o\' HH:mm:ss') - : Utils.getSimpleDate(model.date), + : Utils.getSimpleDate(model.date) + (model.app != null ? " via ${model.app}" : ""), ), Flexible( child: TextButton( From b48170549de92c233711498930595959c33ee2c3 Mon Sep 17 00:00:00 2001 From: unweek Date: Sat, 11 Jan 2020 15:19:53 +0100 Subject: [PATCH 8/8] feat: User app in link comments --- .../link_comment_response.dart | 3 + .../link_comment_response.g.dart | 55 +++++++++++++------ lib/model/link_comment_model.dart | 3 + lib/models/link_comment.dart | 6 +- lib/models/link_comment.g.dart | 53 +++++++++++------- lib/widgets/link/link_comment.dart | 2 +- 6 files changed, 85 insertions(+), 37 deletions(-) diff --git a/lib/api/response_models/link_comment_response.dart b/lib/api/response_models/link_comment_response.dart index fd44cb9..108e9f0 100644 --- a/lib/api/response_models/link_comment_response.dart +++ b/lib/api/response_models/link_comment_response.dart @@ -41,6 +41,9 @@ abstract class LinkCommentResponse @BuiltValueField(wireName: "violation_url") String get violationUrl; + @nullable + String get app; + LinkCommentResponse._(); static Serializer get serializer => _$linkCommentResponseSerializer; diff --git a/lib/api/response_models/link_comment_response.g.dart b/lib/api/response_models/link_comment_response.g.dart index bd4bf2e..ffbb982 100644 --- a/lib/api/response_models/link_comment_response.g.dart +++ b/lib/api/response_models/link_comment_response.g.dart @@ -70,6 +70,12 @@ class _$LinkCommentResponseSerializer ..add(serializers.serialize(object.violationUrl, specifiedType: const FullType(String))); } + if (object.app != null) { + result + ..add('app') + ..add(serializers.serialize(object.app, + specifiedType: const FullType(String))); + } return result; } @@ -133,6 +139,10 @@ class _$LinkCommentResponseSerializer result.violationUrl = serializers.deserialize(value, specifiedType: const FullType(String)) as String; break; + case 'app': + result.app = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + break; } } @@ -165,6 +175,8 @@ class _$LinkCommentResponse extends LinkCommentResponse { final EmbedResponse embed; @override final String violationUrl; + @override + final String app; factory _$LinkCommentResponse( [void Function(LinkCommentResponseBuilder) updates]) => @@ -182,7 +194,8 @@ class _$LinkCommentResponse extends LinkCommentResponse { this.isBlocked, this.author, this.embed, - this.violationUrl}) + this.violationUrl, + this.app}) : super._() { if (id == null) { throw new BuiltValueNullFieldError('LinkCommentResponse', 'id'); @@ -235,7 +248,8 @@ class _$LinkCommentResponse extends LinkCommentResponse { isBlocked == other.isBlocked && author == other.author && embed == other.embed && - violationUrl == other.violationUrl; + violationUrl == other.violationUrl && + app == other.app; } @override @@ -250,18 +264,20 @@ class _$LinkCommentResponse extends LinkCommentResponse { $jc( $jc( $jc( - $jc($jc(0, id.hashCode), - link.hashCode), - date.hashCode), - body.hashCode), - userVote.hashCode), - voteCount.hashCode), - voteCountPlus.hashCode), - parentId.hashCode), - isBlocked.hashCode), - author.hashCode), - embed.hashCode), - violationUrl.hashCode)); + $jc( + $jc($jc(0, id.hashCode), + link.hashCode), + date.hashCode), + body.hashCode), + userVote.hashCode), + voteCount.hashCode), + voteCountPlus.hashCode), + parentId.hashCode), + isBlocked.hashCode), + author.hashCode), + embed.hashCode), + violationUrl.hashCode), + app.hashCode)); } @override @@ -278,7 +294,8 @@ class _$LinkCommentResponse extends LinkCommentResponse { ..add('isBlocked', isBlocked) ..add('author', author) ..add('embed', embed) - ..add('violationUrl', violationUrl)) + ..add('violationUrl', violationUrl) + ..add('app', app)) .toString(); } } @@ -337,6 +354,10 @@ class LinkCommentResponseBuilder String get violationUrl => _$this._violationUrl; set violationUrl(String violationUrl) => _$this._violationUrl = violationUrl; + String _app; + String get app => _$this._app; + set app(String app) => _$this._app = app; + LinkCommentResponseBuilder(); LinkCommentResponseBuilder get _$this { @@ -353,6 +374,7 @@ class LinkCommentResponseBuilder _author = _$v.author?.toBuilder(); _embed = _$v.embed?.toBuilder(); _violationUrl = _$v.violationUrl; + _app = _$v.app; _$v = null; } return this; @@ -388,7 +410,8 @@ class LinkCommentResponseBuilder isBlocked: isBlocked, author: author.build(), embed: _embed?.build(), - violationUrl: violationUrl); + violationUrl: violationUrl, + app: app); } catch (_) { String _$failedField; try { diff --git a/lib/model/link_comment_model.dart b/lib/model/link_comment_model.dart index 53c5459..3332732 100644 --- a/lib/model/link_comment_model.dart +++ b/lib/model/link_comment_model.dart @@ -15,6 +15,7 @@ class LinkCommentModel extends ChangeNotifier { String _linkId; LinkCommentVoteState _voteState; String _violationUrl; + String _app; int get id => _id; String get body => _body; @@ -28,6 +29,7 @@ class LinkCommentModel extends ChangeNotifier { LinkCommentVoteState get voteState => _voteState; bool get isParentComment => _id == _parentId; String get violationUrl => _violationUrl; + String get app => _app; void expand() { _isExpanded = true; @@ -47,6 +49,7 @@ class LinkCommentModel extends ChangeNotifier { _voteCountPlus = comment.voteCountPlus; _voteState = comment.voteState; _violationUrl = comment.violationUrl; + _app = comment.app; notifyListeners(); } diff --git a/lib/models/link_comment.dart b/lib/models/link_comment.dart index a36f6b6..075a342 100644 --- a/lib/models/link_comment.dart +++ b/lib/models/link_comment.dart @@ -41,6 +41,9 @@ abstract class LinkComment implements Built { @nullable String get violationUrl; + @nullable + String get app; + factory LinkComment.mapFromResponse( LinkCommentResponse response) { return _$LinkComment._( @@ -60,7 +63,8 @@ abstract class LinkComment implements Built { embed: (response.embed != null ? Embed.fromResponse(response: response.embed) : null), - violationUrl: response.violationUrl); + violationUrl: response.violationUrl, + app: response.app); } LinkComment._(); diff --git a/lib/models/link_comment.g.dart b/lib/models/link_comment.g.dart index 83db686..b5fe9da 100644 --- a/lib/models/link_comment.g.dart +++ b/lib/models/link_comment.g.dart @@ -37,6 +37,8 @@ class _$LinkComment extends LinkComment { final Embed embed; @override final String violationUrl; + @override + final String app; factory _$LinkComment([void Function(LinkCommentBuilder) updates]) => (new LinkCommentBuilder()..update(updates)).build(); @@ -56,7 +58,8 @@ class _$LinkComment extends LinkComment { this.isBlocked, this.author, this.embed, - this.violationUrl}) + this.violationUrl, + this.app}) : super._() { if (id == null) { throw new BuiltValueNullFieldError('LinkComment', 'id'); @@ -121,7 +124,8 @@ class _$LinkComment extends LinkComment { isBlocked == other.isBlocked && author == other.author && embed == other.embed && - violationUrl == other.violationUrl; + violationUrl == other.violationUrl && + app == other.app; } @override @@ -139,21 +143,25 @@ class _$LinkComment extends LinkComment { $jc( $jc( $jc( - $jc($jc(0, id.hashCode), - date.hashCode), - body.hashCode), - isExpanded.hashCode), - voteCount.hashCode), - voteCountPlus.hashCode), - userVote.hashCode), - linkId.hashCode), - parentId.hashCode), - children.hashCode), - voteState.hashCode), - isBlocked.hashCode), - author.hashCode), - embed.hashCode), - violationUrl.hashCode)); + $jc( + $jc( + $jc(0, + id.hashCode), + date.hashCode), + body.hashCode), + isExpanded.hashCode), + voteCount.hashCode), + voteCountPlus.hashCode), + userVote.hashCode), + linkId.hashCode), + parentId.hashCode), + children.hashCode), + voteState.hashCode), + isBlocked.hashCode), + author.hashCode), + embed.hashCode), + violationUrl.hashCode), + app.hashCode)); } @override @@ -173,7 +181,8 @@ class _$LinkComment extends LinkComment { ..add('isBlocked', isBlocked) ..add('author', author) ..add('embed', embed) - ..add('violationUrl', violationUrl)) + ..add('violationUrl', violationUrl) + ..add('app', app)) .toString(); } } @@ -242,6 +251,10 @@ class LinkCommentBuilder implements Builder { String get violationUrl => _$this._violationUrl; set violationUrl(String violationUrl) => _$this._violationUrl = violationUrl; + String _app; + String get app => _$this._app; + set app(String app) => _$this._app = app; + LinkCommentBuilder(); LinkCommentBuilder get _$this { @@ -261,6 +274,7 @@ class LinkCommentBuilder implements Builder { _author = _$v.author?.toBuilder(); _embed = _$v.embed?.toBuilder(); _violationUrl = _$v.violationUrl; + _app = _$v.app; _$v = null; } return this; @@ -299,7 +313,8 @@ class LinkCommentBuilder implements Builder { isBlocked: isBlocked, author: author.build(), embed: _embed?.build(), - violationUrl: violationUrl); + violationUrl: violationUrl, + app: app); } catch (_) { String _$failedField; try { diff --git a/lib/widgets/link/link_comment.dart b/lib/widgets/link/link_comment.dart index ee48346..60a89b1 100644 --- a/lib/widgets/link/link_comment.dart +++ b/lib/widgets/link/link_comment.dart @@ -187,7 +187,7 @@ class _LinkCommentWidgetState extends State { text: showFullDate ? Utils.getDateFormat( model.date, 'dd.MM.yyyy \'o\' HH:mm:ss') - : Utils.getSimpleDate(model.date), + : Utils.getSimpleDate(model.date) + (model.app != null ? " via ${model.app}" : ""), ), Flexible( child: TextButton(