From 4ac218b065c98731fb5dba5442cbe03db24526b0 Mon Sep 17 00:00:00 2001 From: zoe Date: Sun, 25 Sep 2022 18:09:47 +0200 Subject: [PATCH 01/10] file picker --- lib/business_logic/fileupload/fileupload.dart | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/business_logic/fileupload/fileupload.dart diff --git a/lib/business_logic/fileupload/fileupload.dart b/lib/business_logic/fileupload/fileupload.dart new file mode 100644 index 0000000..60c4fc2 --- /dev/null +++ b/lib/business_logic/fileupload/fileupload.dart @@ -0,0 +1,27 @@ +import 'package:http/http.dart'; + +class FileUpload { + final MultipartFile data; + String description; + final String path; + + // media id for identity, + // gets set after first sucessfully uploading + Map ids = {}; + + FileUpload({ + required this.data, + required this.description, + required this.path, + this.ids = const {}, + }); + + static Future fromPath(String path, String description) async { + final data = await MultipartFile.fromPath("file", path); + return FileUpload( + data: data, + description: description, + path: path, + ); + } +} From 8aa49dc2ea0e4830dd36b955095a2dd62f60783e Mon Sep 17 00:00:00 2001 From: zoe Date: Sun, 25 Sep 2022 18:21:26 +0200 Subject: [PATCH 02/10] media attachments --- lib/business_logic/instance/instance.dart | 4 +- lib/dialogues/makepost.dart | 197 +++++++++++++++++++--- pubspec.lock | 35 +++- pubspec.yaml | 2 + 4 files changed, 205 insertions(+), 33 deletions(-) diff --git a/lib/business_logic/instance/instance.dart b/lib/business_logic/instance/instance.dart index 2b4796b..4fbee9d 100644 --- a/lib/business_logic/instance/instance.dart +++ b/lib/business_logic/instance/instance.dart @@ -29,11 +29,13 @@ class InstanceConfiguration { class StatusConfiguration { final int maxChars; + final int maxMediaAttachments; - StatusConfiguration(this.maxChars); + StatusConfiguration(this.maxChars, this.maxMediaAttachments); static StatusConfiguration fromJson(Map json) { return StatusConfiguration( json["max_characters"], + json["max_media_attachments"], ); } } diff --git a/lib/dialogues/makepost.dart b/lib/dialogues/makepost.dart index 2f74bfe..fa3cee8 100644 --- a/lib/dialogues/makepost.dart +++ b/lib/dialogues/makepost.dart @@ -1,11 +1,14 @@ import 'package:flutter/material.dart'; import 'package:localization/localization.dart'; +import 'package:loris/business_logic/fileupload/fileupload.dart'; import 'package:loris/business_logic/instance/instance.dart'; import 'package:loris/business_logic/network_tools/get_post_from_url.dart'; import 'package:loris/business_logic/timeline/timeline.dart' as tl; import '../business_logic/posting/posting.dart'; import '../partials/post.dart'; import 'package:loris/global.dart' as global; +import 'package:file_picker/file_picker.dart'; +import 'package:mime/mime.dart'; class MakePost extends StatefulWidget { const MakePost({Key? key, this.inReplyTo}) : super(key: key); @@ -18,26 +21,57 @@ class MakePost extends StatefulWidget { class _MakePostState extends State { String replyAts = ""; String accountid = global.settings!.activeIdentity; - int? maxLength; + InstanceInformation? instanceInfo; String text = ""; String spoilerText = ""; + // tracks fileuploads and their ids on servers + // if the id is null the file has not been uploaded yet + List files = []; // stores all identities and if available the post id you are replying to Map identitiesAvailable = {}; tl.Visibility visibility = tl.Visibility.public; void switchAccount(String acct) { setState(() { - maxLength = null; + instanceInfo = null; accountid = acct; }); updateMaxChars(); } + bool tooManyAttachments() { + if (instanceInfo == null) { + return true; + } + if (instanceInfo!.configuration.statusconfig.maxMediaAttachments < + files.length) { + return true; + } + return false; + } + + // moves file in list up or down, + // has to be called with file from items list + void moveFile(FileUpload file, {up = true}) { + if (!mounted) { + return; + } + + final index = files.indexOf(file); + final newIndex = (index + (up ? -1 : 1)) % files.length; + print(newIndex); + + files.remove(file); + setState(() { + files.insert(newIndex, file); + }); + } + void updateMaxChars() async { final info = await instanceInformationForIdentity(accountid); - if (info.keys.first == 200) { + if (info.keys.first == 200 && mounted) { setState(() { - maxLength = info.values.first!.configuration.statusconfig.maxChars; + instanceInfo = info.values.first!; }); } } @@ -100,6 +134,7 @@ class _MakePostState extends State { @override Widget build(BuildContext context) { + // make list of all different widgets to be displayed List c = []; if (widget.inReplyTo != null) { c.add( @@ -140,9 +175,6 @@ class _MakePostState extends State { ))); } List actionButtons = [ - maxLength == null - ? const CircularProgressIndicator() - : SelectableText((maxLength! - text.length).toString()), DropdownButtonHideUnderline( child: DropdownButton( alignment: Alignment.center, @@ -156,6 +188,31 @@ class _MakePostState extends State { }, ), ), + // media attachment button + TextButton.icon( + onPressed: () async { + // open filepicker + FilePickerResult? result = await FilePicker.platform.pickFiles( + withData: false, + allowMultiple: true, + ); + if (result != null) { + // if there are any files + // then parse them + for (var path in result.paths) { + if (path != null && mounted) { + print(path); + final FileUpload f = await FileUpload.fromPath(path, ""); + setState(() { + files.add(f); + }); + } + } + } + }, + icon: const Icon(Icons.attachment), + label: Text( + "${"add-file".i18n()}${instanceInfo == null ? "(${"loading...".i18n()})" : " (${instanceInfo!.configuration.statusconfig.maxMediaAttachments - files.length} ${"remaining".i18n()})"}")), DropdownButtonHideUnderline( child: DropdownButton( alignment: Alignment.center, @@ -173,19 +230,24 @@ class _MakePostState extends State { "send-post".i18n(), ), // send the post!!! - onPressed: () async { - final model = MakePostModel( - spoilerText: spoilerText.trim(), - identity: accountid, - status: text, - visibility: visibility, - inReplyToId: widget.inReplyTo == null - ? null - : identitiesAvailable[accountid]!, - ); - model.sendPost(); - Navigator.of(context).pop(); - }, + onPressed: ((spoilerText.isEmpty && text.isEmpty && files.isEmpty) || + tooManyAttachments()) + ? null + : () async { + final model = MakePostModel( + spoilerText: spoilerText.trim(), + identity: accountid, + status: text, + visibility: visibility, + inReplyToId: widget.inReplyTo == null + ? null + : identitiesAvailable[accountid]!, + ); + final result = await model.sendPost(); + if (result == 200) { + Navigator.of(context).pop(); + } + }, icon: const Icon(Icons.send), ), ]; @@ -194,6 +256,12 @@ class _MakePostState extends State { style: Theme.of(context).textTheme.bodyMedium, initialValue: spoilerText, decoration: InputDecoration( + counterText: instanceInfo == null + ? "loading...".i18n() + : (instanceInfo!.configuration.statusconfig.maxChars - + text.length - + spoilerText.length) + .toString(), prefixIcon: Icon( Icons.warning, color: Theme.of(context).colorScheme.onSurface, @@ -221,6 +289,10 @@ class _MakePostState extends State { const SizedBox( height: 24, ), + ]); + + // these are the action buttons + c.add( Wrap( runSpacing: 8, spacing: 24, @@ -229,7 +301,52 @@ class _MakePostState extends State { alignment: WrapAlignment.spaceAround, children: actionButtons, ), - ]); + ); + + // display media attachments + for (var file in files) { + c.add(Column( + children: [ + FileUploadDisplay(file: file), + TextField( + onChanged: (value) => file.description = value, + style: Theme.of(context).textTheme.bodyMedium, + minLines: 1, + maxLines: null, + decoration: InputDecoration( + hintText: "file-description".i18n(), + ), + ), + Wrap( + children: [ + TextButton.icon( + onPressed: () { + moveFile(file, up: false); + }, + icon: const Icon(Icons.move_down), + label: Text("move-down".i18n()), + ), + TextButton.icon( + onPressed: () => setState(() { + files.remove(file); + }), + icon: const Icon(Icons.delete), + label: Text( + "remove-attached-file".i18n(), + ), + ), + TextButton.icon( + onPressed: () { + moveFile(file); + }, + icon: const Icon(Icons.move_up), + label: Text("move-up".i18n()), + ), + ], + ), + ], + )); + } return SimpleDialog( alignment: Alignment.center, @@ -244,10 +361,7 @@ class _MakePostState extends State { width: (MediaQuery.of(context).size.width * global.settings!.postWidth) - 56, - constraints: BoxConstraints( - maxWidth: global.settings!.maxPostWidth, - minWidth: 375, - ), + constraints: global.getConstraints(context), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, @@ -259,3 +373,36 @@ class _MakePostState extends State { ); } } + +class FileUploadDisplay extends StatelessWidget { + const FileUploadDisplay({super.key, required this.file}); + final FileUpload file; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Divider( + color: Theme.of(context).hintColor, + ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const Icon(Icons.attachment, size: 32), + Expanded( + child: SelectableText( + "${file.path} (${(file.data.length / 1024).toStringAsFixed(2)}kb)", + style: Theme.of(context).textTheme.displaySmall), + ), + ], + ), + if (lookupMimeType(file.path)!.startsWith("image/")) + Image.asset( + file.path, + fit: BoxFit.fitWidth, + ), + ], + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index e95af36..d9a7a00 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -99,6 +99,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.1.4" + file_picker: + dependency: "direct main" + description: + name: file_picker + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.0" flutter: dependency: "direct main" description: flutter @@ -122,7 +129,14 @@ packages: name: flutter_markdown url: "https://pub.dartlang.org" source: hosted - version: "0.6.10+5" + version: "0.6.10+6" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.7" flutter_test: dependency: "direct dev" description: flutter @@ -217,6 +231,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + mime: + dependency: "direct main" + description: + name: mime + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" path: dependency: transitive description: @@ -244,7 +265,7 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" platform: dependency: transitive description: @@ -258,7 +279,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.3" process: dependency: transitive description: @@ -279,7 +300,7 @@ packages: name: shared_preferences_android url: "https://pub.dartlang.org" source: hosted - version: "2.0.12" + version: "2.0.13" shared_preferences_ios: dependency: transitive description: @@ -328,7 +349,7 @@ packages: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.3.2" + version: "1.4.0" sky_engine: dependency: transitive description: flutter @@ -410,7 +431,7 @@ packages: name: url_launcher_android url: "https://pub.dartlang.org" source: hosted - version: "6.0.17" + version: "6.0.19" url_launcher_ios: dependency: transitive description: @@ -480,7 +501,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.7.0" + version: "3.0.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 45daccb..23c23a6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,6 +51,8 @@ dependencies: url_strategy: ^0.2.0 universal_html: ^2.0.8 universal_io: ^2.0.4 + file_picker: ^5.2.0 + mime: ^1.0.2 dev_dependencies: flutter_test: From d0235cac5dafa287847e477ce1fc9b541d78c395 Mon Sep 17 00:00:00 2001 From: zoe Date: Sun, 25 Sep 2022 20:07:47 +0200 Subject: [PATCH 03/10] basic attachments are live --- lib/business_logic/fileupload/fileupload.dart | 38 ++++++++-- lib/business_logic/posting/posting.dart | 7 +- lib/dialogues/makepost.dart | 70 ++++++++++++++++--- 3 files changed, 99 insertions(+), 16 deletions(-) diff --git a/lib/business_logic/fileupload/fileupload.dart b/lib/business_logic/fileupload/fileupload.dart index 60c4fc2..c464366 100644 --- a/lib/business_logic/fileupload/fileupload.dart +++ b/lib/business_logic/fileupload/fileupload.dart @@ -1,7 +1,10 @@ +import 'dart:convert'; + import 'package:http/http.dart'; +import 'package:loris/global.dart' as global; +import 'package:http/http.dart' as http; class FileUpload { - final MultipartFile data; String description; final String path; @@ -10,18 +13,45 @@ class FileUpload { Map ids = {}; FileUpload({ - required this.data, required this.description, required this.path, this.ids = const {}, }); static Future fromPath(String path, String description) async { - final data = await MultipartFile.fromPath("file", path); return FileUpload( - data: data, description: description, path: path, ); } + + /* + sends a media attachments and returns the http status code + if the status code is 200, the String is the media attachments id, + otherwise it's the error response + */ + Future> upload(String identityName) async { + final identity = global.settings!.identities[identityName]!; + final headers = { + ...global.defaultHeaders, + ...identity.getAuthHeaders(), + }; + final uri = + Uri(scheme: "https", host: identity.instanceUrl, path: "/api/v2/media"); + final request = MultipartRequest( + "POST", + uri, + ); + request.headers.addAll(headers); + request.files.add(await MultipartFile.fromPath( + "file", + path, + )); + request.fields.addAll({"description": description}); + final response = await http.Response.fromStream(await request.send()); + if (response.statusCode != 200 && response.statusCode != 202) { + return MapEntry(response.statusCode, jsonDecode(response.body)["error"]); + } + return MapEntry(response.statusCode, jsonDecode(response.body)["id"]); + } } diff --git a/lib/business_logic/posting/posting.dart b/lib/business_logic/posting/posting.dart index 51aa4fd..7106f83 100644 --- a/lib/business_logic/posting/posting.dart +++ b/lib/business_logic/posting/posting.dart @@ -11,17 +11,19 @@ class MakePostModel { final Visibility visibility; final String? scheduledAt; final String? inReplyToId; + List mediaIds; MakePostModel({ required this.identity, required this.status, required this.spoilerText, required this.visibility, + required this.mediaIds, this.scheduledAt, this.inReplyToId, }); - Future sendPost() async { + Future sendPost() async { final headers = global.settings!.identities[identity]!.getAuthHeaders(); headers.addAll(global.defaultHeaders); @@ -29,6 +31,7 @@ class MakePostModel { "status": status, "sensitive": false, "visibility": visibility.queryParam, + "media_ids": mediaIds, }; if (inReplyToId != null) { @@ -55,6 +58,6 @@ class MakePostModel { headers: headers, body: jsonEncode(params), ); - return response.statusCode; + return response; } } diff --git a/lib/dialogues/makepost.dart b/lib/dialogues/makepost.dart index fa3cee8..eda31e3 100644 --- a/lib/dialogues/makepost.dart +++ b/lib/dialogues/makepost.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:flutter/material.dart'; import 'package:localization/localization.dart'; import 'package:loris/business_logic/fileupload/fileupload.dart'; @@ -9,6 +11,7 @@ import '../partials/post.dart'; import 'package:loris/global.dart' as global; import 'package:file_picker/file_picker.dart'; import 'package:mime/mime.dart'; +import 'package:universal_io/io.dart' as io; class MakePost extends StatefulWidget { const MakePost({Key? key, this.inReplyTo}) : super(key: key); @@ -24,6 +27,8 @@ class _MakePostState extends State { InstanceInformation? instanceInfo; String text = ""; String spoilerText = ""; + String? status; + bool sending = false; // tracks fileuploads and their ids on servers // if the id is null the file has not been uploaded yet List files = []; @@ -201,7 +206,7 @@ class _MakePostState extends State { // then parse them for (var path in result.paths) { if (path != null && mounted) { - print(path); + if (await io.Directory(path).exists()) break; final FileUpload f = await FileUpload.fromPath(path, ""); setState(() { files.add(f); @@ -212,7 +217,7 @@ class _MakePostState extends State { }, icon: const Icon(Icons.attachment), label: Text( - "${"add-file".i18n()}${instanceInfo == null ? "(${"loading...".i18n()})" : " (${instanceInfo!.configuration.statusconfig.maxMediaAttachments - files.length} ${"remaining".i18n()})"}")), + "${"add-files".i18n()}${instanceInfo == null ? "(${"loading...".i18n()})" : " (${instanceInfo!.configuration.statusconfig.maxMediaAttachments - files.length} ${"remaining".i18n()})"}")), DropdownButtonHideUnderline( child: DropdownButton( alignment: Alignment.center, @@ -234,7 +239,38 @@ class _MakePostState extends State { tooManyAttachments()) ? null : () async { + setState(() { + sending = true; + status = "sending...".i18n(); + }); + + // upload the media attachments + List mediaIds = []; + for (var file in files) { + if (mounted) { + setState(() { + status = + "${"sending-file".i18n()}${mediaIds.length + 1}/${files.length}"; + }); + } + final response = await file.upload(accountid); + if (response.key == 200 || response.key == 202) { + mediaIds.add(response.value); + break; + } + if (mounted) { + setState(() { + status = response.value; + sending = false; + return; + }); + } + } + print(mediaIds); + + // send the final post final model = MakePostModel( + mediaIds: mediaIds, spoilerText: spoilerText.trim(), identity: accountid, status: text, @@ -244,8 +280,15 @@ class _MakePostState extends State { : identitiesAvailable[accountid]!, ); final result = await model.sendPost(); - if (result == 200) { - Navigator.of(context).pop(); + if (mounted) { + if (result.statusCode == 200) { + Navigator.of(context).pop(); + } + setState(() { + sending = false; + status = + "${"failed-to-send".i18n()}: ${jsonDecode(result.body)["error"].toString()}"; + }); } }, icon: const Icon(Icons.send), @@ -351,10 +394,18 @@ class _MakePostState extends State { return SimpleDialog( alignment: Alignment.center, contentPadding: const EdgeInsets.all(24), - title: SelectableText( - textAlign: TextAlign.center, - widget.inReplyTo == null ? "make-post".i18n() : "make-reply".i18n(), - style: Theme.of(context).textTheme.displayMedium), + title: Column( + children: [ + SelectableText( + textAlign: TextAlign.center, + widget.inReplyTo == null + ? "make-post".i18n() + : "make-reply".i18n(), + style: Theme.of(context).textTheme.displayMedium), + if (status != null) SelectableText(status!), + if (sending) const LinearProgressIndicator(), + ], + ), children: [ SingleChildScrollView( child: Container( @@ -391,8 +442,7 @@ class FileUploadDisplay extends StatelessWidget { children: [ const Icon(Icons.attachment, size: 32), Expanded( - child: SelectableText( - "${file.path} (${(file.data.length / 1024).toStringAsFixed(2)}kb)", + child: SelectableText(file.path, style: Theme.of(context).textTheme.displaySmall), ), ], From 55fb99d9d9126c161cebe79ec14d6b260b709dd9 Mon Sep 17 00:00:00 2001 From: zoe Date: Sun, 25 Sep 2022 20:27:20 +0200 Subject: [PATCH 04/10] went down to api v1 for media attachments --- lib/business_logic/fileupload/fileupload.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/business_logic/fileupload/fileupload.dart b/lib/business_logic/fileupload/fileupload.dart index c464366..fcf8bf5 100644 --- a/lib/business_logic/fileupload/fileupload.dart +++ b/lib/business_logic/fileupload/fileupload.dart @@ -37,7 +37,7 @@ class FileUpload { ...identity.getAuthHeaders(), }; final uri = - Uri(scheme: "https", host: identity.instanceUrl, path: "/api/v2/media"); + Uri(scheme: "https", host: identity.instanceUrl, path: "/api/v1/media"); final request = MultipartRequest( "POST", uri, From f324e43be364407fc186219461f30d3342424daa Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 26 Sep 2022 11:50:00 +0200 Subject: [PATCH 05/10] clean up media attachment update --- lib/dialogues/makepost.dart | 11 +++++------ lib/i18n/en_US.json | 13 ++++++++++++- lib/themes/themes.dart | 13 ++++++------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/dialogues/makepost.dart b/lib/dialogues/makepost.dart index eda31e3..22f5857 100644 --- a/lib/dialogues/makepost.dart +++ b/lib/dialogues/makepost.dart @@ -64,7 +64,6 @@ class _MakePostState extends State { final index = files.indexOf(file); final newIndex = (index + (up ? -1 : 1)) % files.length; - print(newIndex); files.remove(file); setState(() { @@ -247,25 +246,25 @@ class _MakePostState extends State { // upload the media attachments List mediaIds = []; for (var file in files) { + print("blip"); if (mounted) { setState(() { status = - "${"sending-file".i18n()}${mediaIds.length + 1}/${files.length}"; + "${"sending-file".i18n()} ${mediaIds.length + 1}/${files.length}"; }); } final response = await file.upload(accountid); if (response.key == 200 || response.key == 202) { mediaIds.add(response.value); - break; - } - if (mounted) { + } else if (mounted) { setState(() { status = response.value; sending = false; - return; }); + return; } } + print(mediaIds); // send the final post diff --git a/lib/i18n/en_US.json b/lib/i18n/en_US.json index 048d15a..67e8be5 100644 --- a/lib/i18n/en_US.json +++ b/lib/i18n/en_US.json @@ -73,6 +73,17 @@ "instances": "instances", "instance": "instace", "post-found-on": "found post on", - "show-in-full": "show in full" + "show-in-full": "show in full", + "block": "banish", + "unblock": "unbanish", + "add-files": "add files", + "remaining": "remaining", + "move-down": "move down", + "move-up": "move up", + "remove-attached-file": "remove attachment", + "file-description": "file description", + "loading...": "loading", + "failed-to-send": "failed to send!", + "sending-file": "sending file" } \ No newline at end of file diff --git a/lib/themes/themes.dart b/lib/themes/themes.dart index 35f554b..75b6e11 100644 --- a/lib/themes/themes.dart +++ b/lib/themes/themes.dart @@ -75,13 +75,12 @@ ThemeData getTheme(CustomColors colors) { color: colors.colorScheme.onSurface, ), elevatedButtonTheme: ElevatedButtonThemeData( - style: ElevatedButton.styleFrom( - foregroundColor: colors.colorScheme.onPrimary, - textStyle: const TextStyle( - fontFamily: 'Atkinson', - fontSize: 18, - fontWeight: FontWeight.w700, - ), + style: ButtonStyle( + textStyle: MaterialStateProperty.resolveWith((states) => + const TextStyle( + fontSize: 18, + fontFamily: "atkinson", + fontWeight: FontWeight.w700)), ), ), outlinedButtonTheme: OutlinedButtonThemeData( From d077d9a2933cebe067ab49d8b5ecabdfa221dbae Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 26 Sep 2022 12:04:53 +0200 Subject: [PATCH 06/10] clean up colors --- lib/themes/themes.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/themes/themes.dart b/lib/themes/themes.dart index 75b6e11..f8a7961 100644 --- a/lib/themes/themes.dart +++ b/lib/themes/themes.dart @@ -23,7 +23,8 @@ final available = [ ThemeData getTheme(CustomColors colors) { return ThemeData( - floatingActionButtonTheme: const FloatingActionButtonThemeData( + floatingActionButtonTheme: FloatingActionButtonThemeData( + hoverColor: colors.colorScheme.onSurface, elevation: 0, enableFeedback: false, hoverElevation: 24, @@ -76,6 +77,16 @@ ThemeData getTheme(CustomColors colors) { ), elevatedButtonTheme: ElevatedButtonThemeData( style: ButtonStyle( + foregroundColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.disabled)) { + return colors.colorScheme.surface; + } + return null; + }), + backgroundColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.disabled)) return colors.hintColor; + return null; + }), textStyle: MaterialStateProperty.resolveWith((states) => const TextStyle( fontSize: 18, From 8eb4763ff35792119ec69461afb105a358f8e0bc Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 26 Sep 2022 12:06:15 +0200 Subject: [PATCH 07/10] clean up colors on search --- lib/dialogues/search.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/dialogues/search.dart b/lib/dialogues/search.dart index ca4c085..67d19fd 100644 --- a/lib/dialogues/search.dart +++ b/lib/dialogues/search.dart @@ -69,8 +69,9 @@ class _SearchDialogueState extends State { onChanged: ((value) => setState(() { searchText = value; })), - decoration: const InputDecoration( + decoration: InputDecoration( prefixIcon: Icon( + color: Theme.of(context).colorScheme.secondary, Icons.search, ))), if (searched < global.settings!.identities.length && From 2caa91dad59710945f3eb3ff7ab6cb5b44f7e110 Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 26 Sep 2022 12:11:00 +0200 Subject: [PATCH 08/10] clean up make post dialogue --- lib/dialogues/makepost.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/dialogues/makepost.dart b/lib/dialogues/makepost.dart index 22f5857..0e5c64e 100644 --- a/lib/dialogues/makepost.dart +++ b/lib/dialogues/makepost.dart @@ -246,7 +246,6 @@ class _MakePostState extends State { // upload the media attachments List mediaIds = []; for (var file in files) { - print("blip"); if (mounted) { setState(() { status = @@ -265,8 +264,6 @@ class _MakePostState extends State { } } - print(mediaIds); - // send the final post final model = MakePostModel( mediaIds: mediaIds, @@ -391,6 +388,7 @@ class _MakePostState extends State { } return SimpleDialog( + titlePadding: const EdgeInsets.all(0), alignment: Alignment.center, contentPadding: const EdgeInsets.all(24), title: Column( From 3743cd800f2ae50c8f72293adcd4bd58faa2e6b7 Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 26 Sep 2022 12:31:32 +0200 Subject: [PATCH 09/10] clean up theme even more --- lib/themes/themes.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/themes/themes.dart b/lib/themes/themes.dart index f8a7961..e0e2350 100644 --- a/lib/themes/themes.dart +++ b/lib/themes/themes.dart @@ -130,8 +130,6 @@ ThemeData getTheme(CustomColors colors) { errorColor: colors.colorScheme.error, bottomAppBarTheme: BottomAppBarTheme( color: colors.colorScheme.surface, - shape: const CircularNotchedRectangle(), - elevation: 0, ), navigationBarTheme: NavigationBarThemeData( labelTextStyle: MaterialStateProperty.all( @@ -182,6 +180,7 @@ ThemeData getTheme(CustomColors colors) { unselectedWidgetColor: colors.hintColor, toggleableActiveColor: colors.colorScheme.primary, splashColor: colors.colorScheme.onSurface, + splashFactory: NoSplash.splashFactory, highlightColor: colors.hintColor, inputDecorationTheme: InputDecorationTheme( helperStyle: TextStyle( From 4a48a68de4b2028d2a150f60ee62c3e60ca7d423 Mon Sep 17 00:00:00 2001 From: zoe Date: Mon, 26 Sep 2022 12:34:26 +0200 Subject: [PATCH 10/10] add comment --- lib/dialogues/makepost.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dialogues/makepost.dart b/lib/dialogues/makepost.dart index 0e5c64e..16ff73e 100644 --- a/lib/dialogues/makepost.dart +++ b/lib/dialogues/makepost.dart @@ -44,6 +44,7 @@ class _MakePostState extends State { updateMaxChars(); } + // check if there are more attachments than the instance ur posting to allowss bool tooManyAttachments() { if (instanceInfo == null) { return true;