Skip to content

Commit

Permalink
feat: add mouse cursor on LLTappable
Browse files Browse the repository at this point in the history
  • Loading branch information
glemartret committed Feb 20, 2024
1 parent 2a932e8 commit d7d1fbb
Show file tree
Hide file tree
Showing 35 changed files with 1,707 additions and 45 deletions.
30 changes: 30 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: "bae5e49bc2a867403c43b2aae2de8f8c33b037e4"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
- platform: macos
create_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4
base_revision: bae5e49bc2a867403c43b2aae2de8f8c33b037e4

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
65 changes: 65 additions & 0 deletions coverage/lcov.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
SF:lib/src/common_widgets/ll_tappable.dart
DA:14,1
DA:21,0
DA:28,1
DA:30,1
DA:32,1
DA:33,1
DA:35,1
DA:38,1
DA:39,1
DA:41,0
DA:42,0
DA:43,0
DA:44,0
DA:45,0
DA:46,0
DA:48,0
DA:50,3
DA:55,1
DA:57,1
DA:59,3
DA:60,3
DA:63,2
DA:71,0
LF:23
LH:14
end_of_record
SF:lib/src/utils/future_easy_throttle.dart
DA:9,0
DA:12,0
DA:13,0
DA:14,0
DA:15,0
DA:19,0
DA:20,0
DA:21,0
DA:22,0
DA:24,0
DA:28,0
DA:37,0
DA:43,0
DA:45,0
DA:48,0
DA:49,0
DA:51,0
DA:52,0
DA:53,0
DA:54,0
DA:56,0
DA:60,0
DA:63,0
DA:64,0
DA:65,0
DA:68,0
DA:77,0
LF:27
LH:0
end_of_record
SF:lib/src/utils/extensions/completer_extension.dart
DA:4,0
DA:5,0
DA:6,0
LF:3
LH:0
end_of_record
39 changes: 24 additions & 15 deletions lib/src/common_widgets/ll_tappable.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:lm_labs_utils/src/utils/future_easy_throttle.dart';

class LLTappable extends HookWidget {
final Widget child;
final Future<void> Function()? onTap;
final FutureOr<void> Function()? onTap;
final Duration duration;
final Widget Function(Widget) _builder;

Expand All @@ -27,27 +29,34 @@ class LLTappable extends HookWidget {
Widget build(BuildContext context) {
final isProcessing = useState(false);

return GestureDetector(
onTap: isProcessing.value
? null
: () async {
isProcessing.value = true;
await FutureEasyThrottle.throttle(
key.toString(),
duration,
() async => onTap?.call(),
);
isProcessing.value = false;
},
child: _builder(child),
return MouseRegion(
cursor: isProcessing.value
? SystemMouseCursors.wait
: (onTap != null)
? SystemMouseCursors.click
: MouseCursor.defer,
child: GestureDetector(
onTap: isProcessing.value
? null
: () async {
isProcessing.value = true;
await FutureEasyThrottle.throttle(
key.toString(),
duration,
() async => onTap?.call(),
);
isProcessing.value = false;
},
child: _builder(child),
),
);
}

@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(ObjectFlagProperty<Future<void> Function()?>.has('onTap', onTap))
..add(ObjectFlagProperty<FutureOr<void> Function()?>.has('onTap', onTap))
..add(DiagnosticsProperty<Duration>('duration', duration));
}

Expand Down
7 changes: 7 additions & 0 deletions macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Flutter-related
**/Flutter/ephemeral/
**/Pods/

# Xcode-related
**/dgph
**/xcuserdata/
2 changes: 2 additions & 0 deletions macos/Flutter/Flutter-Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
2 changes: 2 additions & 0 deletions macos/Flutter/Flutter-Release.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "ephemeral/Flutter-Generated.xcconfig"
12 changes: 12 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Generated file. Do not edit.
//

import FlutterMacOS
import Foundation

import connectivity_plus

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
}
43 changes: 43 additions & 0 deletions macos/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
platform :osx, '10.14'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\""
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_macos_podfile_setup

target 'Runner' do
use_frameworks!
use_modular_headers!

flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
end
end
29 changes: 29 additions & 0 deletions macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
PODS:
- connectivity_plus (0.0.1):
- FlutterMacOS
- ReachabilitySwift
- FlutterMacOS (1.0.0)
- ReachabilitySwift (5.0.0)

DEPENDENCIES:
- connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)

SPEC REPOS:
trunk:
- ReachabilitySwift

EXTERNAL SOURCES:
connectivity_plus:
:path: Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos
FlutterMacOS:
:path: Flutter/ephemeral

SPEC CHECKSUMS:
connectivity_plus: 18d3c32514c886e046de60e9c13895109866c747
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825

PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367

COCOAPODS: 1.14.3
Loading

0 comments on commit d7d1fbb

Please sign in to comment.