Release/1.4.0 beta (#318)

* fix: fixed long system messages overflowing

* fix: fixed long system messages overflowing

* [UI-Kit] Refactor, add support for downloading attachments.

Signed-off-by: Sahil Kumar <[email protected]>

* fix: header casing

* [UI-Kit] Disable attachment download dialog pop using back button

Signed-off-by: Sahil Kumar <[email protected]>

* stream_chat_flutter fix svg on web

* [UI-Kit] Pop attachment download dialog in case of any error.

Signed-off-by: Sahil Kumar <[email protected]>

* restore svg

* feat: add pr title linter

* fix test

* fix client headers

* update system message design

* update gh token env var

* add scopes

* expose systemMessageBuilder in messagelistview

* fix(ui): fix button size

* add dispatch workflow

* add dispatch workflow

* update dispatch acton

* add runson

* fix ref

* fix ref

* update secret

* specify repo

* fix: list scroll keyboard behaviour  (#304)

* fix: Keyboard now closes by clicking on space or scrolling.

* fix: Exposed system and normal message tap builders

* fmt: dartfmt

* feat: Add support for messages filter in `MessageListView` and `MessageListCore` (#303)

* [MessageListView, MessageListCore] Add support for message filter

Signed-off-by: Sahil Kumar <[email protected]>

* [UI-Kit -> Pubspec] Remove `stream_chat_flutter_core` relative import

Signed-off-by: Sahil Kumar <[email protected]>

* add relative import

* add relative import

* remove svg for web

* remove badge logic on web

* style: Update for team lint (#297)

* Update for team lint

* fix tests

* remove pedantic and sort deps

* remove jiffy from system message

Co-authored-by: Salvatore Giordano <[email protected]>

* add section highlighting sample app repo (#307)

Co-authored-by: Salvatore Giordano <[email protected]>

* add null check to debounce

* fix messagelistview loading errors

* remove core relative import

* fix: fixes message newline issue (#308)

* fix: minor

* fix: generate image thumbnails and use transparent image as placeholder for cached network images (#310)

* update cdn handling

* fix image attachment with new cdn

* fix(ui): Fix message input permission request crash (#311)

Signed-off-by: Sahil Kumar <[email protected]>

* fix(llc): update member presence and add skip_push to message (#314)

* update member presence

* add skip_push to message

* fix tests

* fix: Fixed shimmer overflow (#316)

* fix dialogs

* fix(llc): Fix attachment upload state uneven progress. (#315)

* feat(llc): Add rate limiter functions.
fix(llc): Fix attachment upload state uneven progress.

Signed-off-by: Sahil Kumar <[email protected]>

* feat(llc): Export `async.dart` and `rate_limit.dart`

Signed-off-by: Sahil Kumar <[email protected]>

* refactor(llc): Replace our `rate_limit` implementation with the dart port of js `lodash` to better handlw `cancel` and `flush` functions.

Signed-off-by: Sahil Kumar <[email protected]>

* fix(UI-Kit): Make android example run on real devices

Signed-off-by: Sahil Kumar <[email protected]>

* fix offline behaviour

Co-authored-by: Salvatore Giordano <[email protected]>

* feat: Introduce onAttachmentTap on messages attachment (#309)

* introdce onAttachmentTap on message

* correct indent

* sdfsd

Co-authored-by: Salvatore Giordano <[email protected]>

* feat: added customization options in main widgets (#312)

* polish channelpreview customization options

* polish channelheader customization options

* polish messageinput customization options

* polish threadheader customization options

* polish channellistheader customization options

* show the parent message if no messages in thread

* fix edit message

* fix channelinfo textstyle

* fix review

* fix useravatar

* add ontitle tap to thread header

* add custom message actions

* add borderradius and button builder

* add ontap to messageinput custom send button

* fix bottom sheet

* add doc

* use placeholder image

* add doc

* fix listtile density

* remove subtitle from ChannelListHeaderTheme.copyWith

* add InputDecoration.merge extension

* fix: use shimmer in images

* fix: remove notification badge logic from the sdk and move it to sample app

* fix import

* fix: Method being called during build (#317)

* method call bug fix

* dartfmt

* fix: show error messages as system and keep them in the message input (#319)

* fix: pre release (#324)

* use share_plus plugin

* bump dependency versions

* fix ui for web

* unfocus messageinput only on commands

* fix default error for messagesearchlistview

* fix thumbnail animation

* fix lint

* ignore example in linter

* update changelogs

* fix lint

* fix lint

* update stream_chat pana min

* add doc

Co-authored-by: Sahil Kumar <[email protected]>
Co-authored-by: Deven Joshi <[email protected]>
Co-authored-by: Neevash Ramdial (Nash) <[email protected]>
Co-authored-by: Nelson Nunes <[email protected]>
This commit is contained in:
Salvatore Giordano
2021-03-09 18:58:23 +01:00
committed by GitHub
co-authored by Sahil Kumar Deven Joshi Neevash Ramdial Nelson Nunes
parent 3332a48a0e
commit 4488fa6c3a
121 changed files with 3768 additions and 2376 deletions
@@ -1,7 +1,6 @@
/// Useful extension functions for [Map]
extension MapX on Map {
/// Returns a new map with null keys or values removed
Map<String, dynamic> get nullProtected {
return {...this}..removeWhere((key, value) => key == null || value == null);
}
Map<String, dynamic> get nullProtected =>
{...this}..removeWhere((key, value) => key == null || value == null);
}
@@ -0,0 +1,335 @@
// ignore_for_file: lines_longer_than_80_chars
import 'dart:async' show Timer;
import 'dart:math' as math;
/// Useful rate limiter extensions for [Function] class.
extension RateLimit on Function {
/// Converts this into a [Debounce] function.
Debounce debounced(
Duration wait, {
bool leading = false,
bool trailing = true,
Duration maxWait,
}) =>
Debounce(
this,
wait,
leading: leading,
trailing: trailing,
maxWait: maxWait,
);
/// Converts this into a [Throttle] function.
Throttle throttled(
Duration wait, {
bool leading = true,
bool trailing = true,
}) =>
Throttle(
this,
wait,
leading: leading,
trailing: trailing,
);
}
/// TopLevel lambda to create [Debounce] functions.
Debounce debounce(
Function func,
Duration wait, {
bool leading = false,
bool trailing = true,
Duration maxWait,
}) =>
Debounce(
func,
wait,
leading: leading,
trailing: trailing,
maxWait: maxWait,
);
/// TopLevel lambda to create [Throttle] functions.
Throttle throttle(
Function func,
Duration wait, {
bool leading = true,
bool trailing = true,
}) =>
Throttle(
func,
wait,
leading: leading,
trailing: trailing,
);
/// Creates a debounced function that delays invoking `func` until after `wait`
/// milliseconds have elapsed since the last time the debounced function was
/// invoked. The debounced function comes with a [Debounce.cancel] method to cancel
/// delayed `func` invocations and a [Debounce.flush] method to immediately invoke them.
/// Provide `leading` and/or `trailing` to indicate whether `func` should be
/// invoked on the `leading` and/or `trailing` edge of the `wait` interval.
/// The `func` is invoked with the last arguments provided to the [call]
/// function. Subsequent calls to the debounced function return the result of
/// the last `func` invocation.
///
/// **Note:** If `leading` and `trailing` options are `true`, `func` is
/// invoked on the trailing edge of the timeout only if the debounced function
/// is invoked more than once during the `wait` timeout.
///
/// If `wait` is [Duration.zero] and `leading` is `false`,
/// `func` invocation is deferred until the next tick.
///
/// See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
/// for details over the differences between [Debounce] and [Throttle].
///
/// Some examples:
///
/// Avoid calling costly network calls when user is typing something.
/// ```dart
/// void fetchData(String query) async {
/// final data = api.getData(query);
/// doSomethingWithTheData(data);
/// }
///
/// final debouncedFetchData = Debounce(
/// fetchData,
/// const Duration(milliseconds: 350),
/// );
///
/// void onSearchQueryChanged(query) {
/// debouncedFetchData(query);
/// }
/// ```
///
/// Cancel the trailing debounced invocation.
/// ```dart
/// void dispose() {
/// debounced.cancel();
/// }
/// ```
///
/// Check for pending invocations.
/// ```dart
/// final status = debounced.isPending ? "Pending..." : "Ready";
/// ```
class Debounce {
/// Creates a new instance of [Debounce].
Debounce(
this._func,
Duration wait, {
bool leading = false,
bool trailing = true,
Duration maxWait,
}) : _leading = leading,
_trailing = trailing,
_wait = wait?.inMilliseconds ?? 0,
_maxing = maxWait != null {
if (_maxing) {
_maxWait = math.max(maxWait.inMilliseconds, _wait);
}
}
final Function _func;
final bool _leading;
final bool _trailing;
final int _wait;
final bool _maxing;
int _maxWait;
List<Object> _lastArgs;
Map<Symbol, Object> _lastNamedArgs;
Timer _timer;
int _lastCallTime;
Object _result;
int _lastInvokeTime = 0;
Object _invokeFunc(int time) {
final args = _lastArgs;
final namedArgs = _lastNamedArgs;
_lastArgs = _lastNamedArgs = null;
_lastInvokeTime = time;
return _result = Function.apply(_func, args, namedArgs);
}
Timer _startTimer(Function pendingFunc, int wait) =>
Timer(Duration(milliseconds: wait), pendingFunc);
bool _shouldInvoke(int time) {
final timeSinceLastCall = time - (_lastCallTime ?? double.nan);
final timeSinceLastInvoke = time - _lastInvokeTime;
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return _lastCallTime == null ||
(timeSinceLastCall >= _wait) ||
(timeSinceLastCall < 0) ||
(_maxing && timeSinceLastInvoke >= _maxWait);
}
Object _trailingEdge(int time) {
_timer = null;
// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
if (_trailing && _lastArgs != null) {
return _invokeFunc(time);
}
_lastArgs = _lastNamedArgs = null;
return _result;
}
int _remainingWait(int time) {
final timeSinceLastCall = time - _lastCallTime;
final timeSinceLastInvoke = time - _lastInvokeTime;
final timeWaiting = _wait - timeSinceLastCall;
return _maxing
? math.min(timeWaiting, _maxWait - timeSinceLastInvoke)
: timeWaiting;
}
void _timerExpired() {
final time = DateTime.now().millisecondsSinceEpoch;
if (_shouldInvoke(time)) {
_trailingEdge(time);
} else {
// Restart the timer.
_timer = _startTimer(_timerExpired, _remainingWait(time));
}
}
Object _leadingEdge(int time) {
// Reset any `maxWait` timer.
_lastInvokeTime = time;
// Start the timer for the trailing edge.
_timer = _startTimer(_timerExpired, _wait);
// Invoke the leading edge.
return _leading ? _invokeFunc(time) : _result;
}
/// Cancels all the remaining delayed functions.
void cancel() {
_timer?.cancel();
_lastInvokeTime = 0;
_lastArgs = _lastNamedArgs = _lastCallTime = _timer = null;
}
/// Immediately invokes all the remaining delayed functions.
Object flush() {
final now = DateTime.now().millisecondsSinceEpoch;
return _timer == null ? _result : _trailingEdge(now);
}
/// True if there are functions remaining to get invoked.
bool get isPending => _timer != null;
/// Calls/invokes this class like a function.
/// Pass [args] and [namedArgs] to be used while invoking [_func].
Object call(
List<dynamic> args, {
Map<Symbol, dynamic> namedArgs,
}) {
final time = DateTime.now().millisecondsSinceEpoch;
final isInvoking = _shouldInvoke(time);
_lastArgs = args;
_lastNamedArgs = namedArgs;
_lastCallTime = time;
if (isInvoking) {
if (_timer == null) {
return _leadingEdge(_lastCallTime);
}
if (_maxing) {
// Handle invocations in a tight loop.
_timer = _startTimer(_timerExpired, _wait);
return _invokeFunc(_lastCallTime);
}
}
_timer ??= _startTimer(_timerExpired, _wait);
return _result;
}
}
/// Creates a throttled function that only invokes `func` at most once per
/// every `wait` milliseconds. The throttled function comes with a [Throttle.cancel]
/// method to cancel delayed `func` invocations and a [Throttle.flush] method to
/// immediately invoke them. Provide `leading` and/or `trailing` to indicate
/// whether `func` should be invoked on the `leading` and/or `trailing` edge of the `wait` timeout.
/// The `func` is invoked with the last arguments provided to the
/// throttled function. Subsequent calls to the throttled function return the
/// result of the last `func` invocation.
///
/// **Note:** If `leading` and `trailing` options are `true`, `func` is
/// invoked on the trailing edge of the timeout only if the throttled function
/// is invoked more than once during the `wait` timeout.
///
/// If `wait` is [Duration.zero] and `leading` is `false`, `func` invocation is deferred
/// until the next tick.
///
/// See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
/// for details over the differences between [Throttle] and [Debounce].
///
/// Some examples:
///
/// Avoid excessively rebuilding UI progress while uploading data to server.
/// ```dart
/// void updateUI(Data data) {
/// updateProgress(data);
/// }
///
/// final throttledUpdateUI = Throttle(
/// updateUI,
/// const Duration(milliseconds: 350),
/// );
///
/// void onUploadProgressChanged(progress) {
/// throttledUpdateUI(progress);
/// }
/// ```
///
/// Cancel the trailing throttled invocation.
/// ```dart
/// void dispose() {
/// throttled.cancel();
/// }
/// ```
///
/// Check for pending invocations.
/// ```dart
/// final status = throttled.isPending ? "Pending..." : "Ready";
/// ```
class Throttle {
/// Creates a new instance of [Throttle]
Throttle(
Function func,
Duration wait, {
bool leading = true,
bool trailing = true,
}) : _debounce = Debounce(
func,
wait,
leading: leading,
trailing: trailing,
maxWait: wait,
);
final Debounce _debounce;
/// Cancels all the remaining delayed functions.
void cancel() => _debounce.cancel();
/// Immediately invokes all the remaining delayed functions.
Object flush() => _debounce.flush();
/// True if there are functions remaining to get invoked.
bool get isPending => _debounce.isPending;
/// Calls/invokes this class like a function.
/// Pass [args] and [namedArgs] to be used while invoking `func`.
Object call(List<dynamic> args, {Map<Symbol, dynamic> namedArgs}) =>
_debounce.call(args, namedArgs: namedArgs);
}