diff --git a/README.md b/README.md index 0fe2a1b..890c11a 100644 --- a/README.md +++ b/README.md @@ -156,9 +156,39 @@ Or, try the Nix package: `nix run git+https://git.federated.nexus/Henry-Hiles/ne - With Nix: Either use direnv and `direnv allow`, or `nix flake develop` - Without Nix: Install Flutter, Go, Git, Libclang, and Glibc. Do not use any Snap packages, they cause various compilation issues. -#### Windows / MacOS +#### Windows -I don't really know. You will need Flutter, Git, Go, and Visual Studio tools, and otherwise I guess just keep installing stuff until there aren't any errors. I will look into this sometimeTM. +You will need: + +- Flutter +- Android SDK + NDK +- Git +- Go +- Visual Studio 2022 (Desktop development with C++) +- [MSYS2/MinGW-w64 GCC](https://www.msys2.org/) (for CGO) +- [LLVM/Clang + libclang](https://clang.llvm.org/get_started.html) (for `ffigen`) + +On Windows, make sure these are available in your shell `PATH`: + +- `C:\msys64\ucrt64\bin` (or your MinGW bin path containing `x86_64-w64-mingw32-gcc.exe`) +- `C:\Program Files\LLVM\bin` (contains `clang.exe` and `libclang.dll`) + +Also make sure Go build cache env vars are present (PowerShell): + +```powershell +$env:LOCALAPPDATA = "C:\Users\\AppData\Local" +$env:GOCACHE = "$env:LOCALAPPDATA\go-build" +``` + +For `dart scripts/generate.dart`, you may also need: + +```powershell +$env:CPATH = "C:\msys64\ucrt64\include" +``` + +#### MacOS + +Similar prerequisites apply (Flutter, Git, Go, C toolchain, LLVM/libclang), but exact setup has not been fully documented yet. ### Clone repo diff --git a/lib/controllers/emoji_controller.dart b/lib/controllers/emoji_controller.dart deleted file mode 100644 index 358f98b..0000000 --- a/lib/controllers/emoji_controller.dart +++ /dev/null @@ -1,88 +0,0 @@ -import "dart:convert"; -import "package:emoji_text_field/models/emoji_category.dart"; -import "package:fast_immutable_collections/fast_immutable_collections.dart"; -import "package:flutter/material.dart"; -import "package:flutter_riverpod/flutter_riverpod.dart"; -import "package:http/http.dart"; -import "package:nexus/models/emoji.dart"; - -typedef EmojiTuple = (IMap, IMap>); - -class EmojiController extends AsyncNotifier { - @override - Future build() async { - final response = await get( - Uri.https( - "github.com", - "github/gemoji/raw/refs/heads/master/db/emoji.json", - ), - ); - - if (response.statusCode != 200) { - throw Exception("Failed to load emoji data"); - } - - final data = json.decode(response.body); - - final entries = (data as List) - .cast>() - .map(Emoji.fromJson) - .toIList(); - - final categoryMap = entries.fold>>( - const IMap.empty(), - (acc, entry) => acc.update( - entry.category, - (list) => list.add(entry.emoji), - ifAbsent: () => IList([entry.emoji]), - ), - ); - - final keywordMap = entries.fold>>( - const IMap.empty(), - (acc, entry) => acc.add( - entry.emoji, - IList([...entry.tags, ...entry.aliases, entry.description]), - ), - ); - - final customCategories = IMap.fromEntries( - categoryMap.entries.map( - (entry) => MapEntry( - entry.key, - EmojiCategory( - name: entry.key, - icon: switch (entry.key) { - "Smileys & Emotion" => Icons.emoji_emotions, - "People & Body" => Icons.emoji_people, - "Animals & Nature" => Icons.emoji_nature, - "Food & Drink" => Icons.emoji_food_beverage, - "Travel & Places" => Icons.travel_explore, - "Activities" => Icons.sports_soccer, - "Objects" => Icons.emoji_objects, - "Symbols" => Icons.emoji_symbols, - "Flags" => Icons.emoji_flags, - _ => Icons.category, - }, - emojis: entry.value.toList(growable: false), - ), - ), - ), - ); - - final customKeywords = IMap( - Map.fromEntries( - keywordMap.entries.map( - (e) => MapEntry(e.key, e.value.toList(growable: false)), - ), - ), - ); - - return (customCategories, customKeywords); - } - - static final provider = - AsyncNotifierProvider.autoDispose( - EmojiController.new, - ); -} diff --git a/lib/models/emoji.dart b/lib/models/emoji.dart deleted file mode 100644 index 8e4eac6..0000000 --- a/lib/models/emoji.dart +++ /dev/null @@ -1,17 +0,0 @@ -import "package:fast_immutable_collections/fast_immutable_collections.dart"; -import "package:freezed_annotation/freezed_annotation.dart"; -part "emoji.freezed.dart"; -part "emoji.g.dart"; - -@freezed -abstract class Emoji with _$Emoji { - const factory Emoji({ - required String emoji, - required String category, - required IList aliases, - required String description, - required IList tags, - }) = _Emoji; - - factory Emoji.fromJson(Map json) => _$EmojiFromJson(json); -} diff --git a/lib/widgets/chat_page/emoji_picker_button.dart b/lib/widgets/chat_page/emoji_picker_button.dart index e8805ca..0c43c48 100644 --- a/lib/widgets/chat_page/emoji_picker_button.dart +++ b/lib/widgets/chat_page/emoji_picker_button.dart @@ -1,9 +1,8 @@ import "package:emoji_text_field/emoji_text_field.dart"; import "package:flutter/material.dart"; -import "package:hooks_riverpod/hooks_riverpod.dart"; -import "package:nexus/controllers/emoji_controller.dart"; +import "package:flutter_hooks/flutter_hooks.dart"; -class EmojiPickerButton extends HookConsumerWidget { +class EmojiPickerButton extends HookWidget { final TextEditingController? controller; final void Function(String emoji)? onSelection; final VoidCallback? onPressed; @@ -17,34 +16,25 @@ class EmojiPickerButton extends HookConsumerWidget { }); @override - Widget build(_, WidgetRef ref) => IconButton( - onPressed: () async { + Widget build(_) => IconButton( + onPressed: () { onPressed?.call(); final controller = this.controller ?? TextEditingController(); - - final emojis = await ref.watch(EmojiController.provider.future); - if (context.mounted) { - showModalBottomSheet( - context: context, - builder: (context) => EmojiKeyboardView( - config: EmojiViewConfig( - showRecentTab: false, - customCategories: emojis.$1.unlock, - customKeywords: emojis.$2.unlock, - backgroundColor: Theme.of(context).colorScheme.surfaceContainer, - height: 600, - ), - textController: controller - ..addListener(() { - // Without this, there will sometimes be a debugLocked is not true error sometimes - Future.delayed(Duration.zero, () { - if (context.mounted) Navigator.of(context).pop(); - }); - onSelection?.call(controller.text); - }), + showModalBottomSheet( + context: context, + builder: (context) => EmojiKeyboardView( + config: EmojiViewConfig( + showRecentTab: false, + backgroundColor: Theme.of(context).colorScheme.surfaceContainer, + height: 600, ), - ); - } + textController: controller + ..addListener(() async { + Navigator.of(context).pop(); + onSelection?.call(controller.text); + }), + ), + ); }, icon: Icon(Icons.emoji_emotions), ); diff --git a/linux/nix/pkg/default.nix b/linux/nix/pkg/default.nix index adaeb15..26f2a17 100644 --- a/linux/nix/pkg/default.nix +++ b/linux/nix/pkg/default.nix @@ -26,7 +26,7 @@ flutter.buildFlutterApplication { dynamic_system_colors = "sha256-es6rjMK1drkqZBKYUP77yw/q5+0uLwWOEDOXRawy3Dc="; flutter_chat_ui = "sha256-4fuag7lRH5cMBFD3fUzj2K541JwXLoz8HF/4OMr3uhk="; flutter_link_previewer = "sha256-4fuag7lRH5cMBFD3fUzj2K541JwXLoz8HF/4OMr3uhk="; - emoji_text_field = "sha256-3TOys09EP2GRo6pUBGPXaqBlE39O2Cmwt42Hs1cTDKo="; + emoji_text_field = "sha256-F0QbIHP3wpKoL6QbJ20Oun0SsOdwnXe84IqsK2ad85w="; }; postInstall = '' diff --git a/pubspec.lock b/pubspec.lock index 984341b..ef7fcd9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -359,7 +359,7 @@ packages: description: path: "." ref: HEAD - resolved-ref: "5f7baaf8a6f059ec3ab8ff0f5d02339b00bf6997" + resolved-ref: "0e90703a6e876939be70bd1816c49cf14474de61" url: "https://github.com/Henry-Hiles/emoji_text_field" source: git version: "1.0.0"