Skip to content

Commit

Permalink
Upgrade flutter & dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
robertodoering committed May 29, 2023
1 parent 971ddd6 commit 2f008d7
Show file tree
Hide file tree
Showing 10 changed files with 321 additions and 264 deletions.
45 changes: 23 additions & 22 deletions lib/api/twitter/tweet_text_count.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/widgets.dart';
import 'package:harpy/core/core.dart';
import 'package:logging/logging.dart';

/// The count of weighted characters for a tweet.
///
Expand All @@ -21,10 +22,10 @@ int tweetTextCount(String text) {

final urlsLength = urls * 23;
final emojisLength = emojis * 2;
final normalWeigthedCharacters = normalWeighted.length;
final normalWeightedCharacters = normalWeighted.length;
final otherCharacters = text.codeUnits.length * 2;

return urlsLength + emojisLength + normalWeigthedCharacters + otherCharacters;
return urlsLength + emojisLength + normalWeightedCharacters + otherCharacters;
}

/// Regex to match the code unit ranges for unicode glyphs that are weighted as
Expand Down Expand Up @@ -59,33 +60,33 @@ int _uniqueEmojis(String text) {

final emojiMatches = emojiRegex.allMatches(text);

if (emojiMatches.isNotEmpty) {
try {
final emojiGroups = <String>[];
if (emojiMatches.isEmpty) return 0;

var prevEnd = -1;
var group = -1;
try {
final emojiGroups = <String>[];

for (final match in emojiMatches) {
final start = match.start;
final end = match.end;
var prevEnd = -1;
var group = -1;

if (start == prevEnd) {
emojiGroups[group] += text.substring(start, end);
} else {
emojiGroups.add(text.substring(start, end));
group++;
}
for (final match in emojiMatches) {
final start = match.start;
final end = match.end;

prevEnd = end;
if (start == prevEnd) {
emojiGroups[group] += text.substring(start, end);
} else {
emojiGroups.add(text.substring(start, end));
group++;
}

for (final emojiGroup in emojiGroups) {
uniqueEmojis += Characters(emojiGroup).length;
}
} catch (e) {
// ignore potential parsing errors
prevEnd = end;
}

for (final emojiGroup in emojiGroups) {
uniqueEmojis += Characters(emojiGroup).length;
}
} catch (e, st) {
Logger('$tweetTextCount').warning('error counting emojis in $text', e, st);
}

return uniqueEmojis;
Expand Down
4 changes: 2 additions & 2 deletions lib/components/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class _LoginPageState extends ConsumerState<LoginPage> {
constraints: BoxConstraints(
maxHeight: mediaQuery.size.height * .5,
),
child: Column(
children: const [
child: const Column(
children: [
Expanded(child: _HarpyTitle()),
Expanded(child: _HarpyLogo()),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/components/pages/user/model/user_page_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class UserPageData with _$UserPageData {
required UserData user,
String? bannerUrl,
@Default(DescriptionTranslationState.untranslated())
DescriptionTranslationState descriptionTranslationState,
DescriptionTranslationState descriptionTranslationState,
LegacyTweetData? pinnedTweet,
RelationshipData? relationship,
}) = _UserPageData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class HomeTimelineTopActions extends StatelessWidget {
return SliverToBoxAdapter(
child: Padding(
padding: theme.spacing.edgeInsets.copyWith(bottom: 0),
child: Row(
children: const [
child: const Row(
children: [
_RefreshButton(),
Spacer(),
_ComposeButton(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ class TrendsPlaceholder extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Row(
return const Row(
children: [
const PlaceholderBox(width: 28, height: 28, shape: BoxShape.circle),
PlaceholderBox(width: 28, height: 28, shape: BoxShape.circle),
HorizontalSpacer.normal,
HorizontalSpacer.normal,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
children: [
PlaceholderBox(widthFactor: .75, height: 15),
VerticalSpacer.small,
PlaceholderBox(widthFactor: .3, height: 15),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ class TweetPlaceholder extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Column(
return const Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const PlaceholderBox(width: 42, height: 42, shape: BoxShape.circle),
PlaceholderBox(width: 42, height: 42, shape: BoxShape.circle),
HorizontalSpacer.normal,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
children: [
PlaceholderBox(widthFactor: .75, height: 15),
VerticalSpacer.small,
PlaceholderBox(widthFactor: .5, height: 15),
Expand All @@ -66,11 +66,11 @@ class TweetPlaceholder extends StatelessWidget {
],
),
VerticalSpacer.normal,
const PlaceholderBox(widthFactor: .6, height: 15),
PlaceholderBox(widthFactor: .6, height: 15),
VerticalSpacer.small,
const PlaceholderBox(height: 15),
PlaceholderBox(height: 15),
VerticalSpacer.small,
const PlaceholderBox(widthFactor: .8, height: 15),
PlaceholderBox(widthFactor: .8, height: 15),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class UserPlaceholder extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Row(
return const Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const PlaceholderBox(width: 42, height: 42, shape: BoxShape.circle),
PlaceholderBox(width: 42, height: 42, shape: BoxShape.circle),
HorizontalSpacer.normal,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
children: [
PlaceholderBox(widthFactor: .75, height: 15),
VerticalSpacer.small,
PlaceholderBox(widthFactor: .3, height: 15),
Expand Down
Loading

0 comments on commit 2f008d7

Please sign in to comment.