Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:thunder-app/thunder into feature…
Browse files Browse the repository at this point in the history
…/additional-font-scales
  • Loading branch information
hjiangsu committed Jan 17, 2024
2 parents 2464b26 + a6f5ded commit bff523e
Show file tree
Hide file tree
Showing 30 changed files with 4,398 additions and 1,413 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
branches:
- develop
workflow_dispatch:

jobs:
linting:
Expand All @@ -23,11 +24,27 @@ jobs:
cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:' # optional, change this to specify the cache path
architecture: x64 # optional, x64 or arm64

- name: Create Empty .env File
run: echo "#" > .env

- name: Dependencies
run: flutter pub get

- name: Install arb_utils to check sorting of translations
run: dart pub global activate arb_utils

- name: Copy translation file
run: cp ./lib/l10n/app_en.arb ./lib/l10n/app_en_tmp.arb

- name: Sort translation .arb file alphabetically
run: arb_utils sort ./lib/l10n/app_en.arb

- name: Check sorted translations against reference
run: |
# Check if the contents of the destination file match the reference file
if cmp -s "./lib/l10n/app_en.arb" "./lib/l10n/app_en_tmp.arb"; then
echo "Translation entries are in alphabetical order."
else
echo "Translation entries are not in alphabetical order."
exit 1 # Fail the workflow if files are not the same
fi
- name: Linting
# We'll ignore info and warnings when performing this step
Expand Down
22 changes: 20 additions & 2 deletions lib/community/pages/create_post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import 'package:thunder/shared/snackbar.dart';
import 'package:thunder/utils/debounce.dart';
import 'package:thunder/utils/image.dart';
import 'package:thunder/utils/instance.dart';
import 'package:thunder/utils/navigate_post.dart';

class CreatePostPage extends StatefulWidget {
final int? communityId;
Expand All @@ -61,6 +62,9 @@ class CreatePostPage extends StatefulWidget {
/// Callback function that is triggered whenever the post is successfully created or updated
final Function(PostViewMedia postViewMedia)? onPostSuccess;

// The scaffold key for the main Thunder page
final GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey;

const CreatePostPage({
super.key,
required this.communityId,
Expand All @@ -72,6 +76,7 @@ class CreatePostPage extends StatefulWidget {
this.prePopulated = false,
this.postView,
this.onPostSuccess,
this.scaffoldMessengerKey,
});

@override
Expand Down Expand Up @@ -337,9 +342,10 @@ class _CreatePostPageState extends State<CreatePostPage> {
child: IconButton(
onPressed: isSubmitButtonDisabled
? null
: () {
: () async {
draftPost.saveAsDraft = false;
context.read<CreatePostCubit>().createOrEditPost(

final int? postId = await context.read<CreatePostCubit>().createOrEditPost(
communityId: communityId!,
name: _titleTextController.text,
body: _bodyTextController.text,
Expand All @@ -348,6 +354,18 @@ class _CreatePostPageState extends State<CreatePostPage> {
postIdBeingEdited: widget.postView?.post.id,
languageId: languageId,
);

if (context.mounted && widget.scaffoldMessengerKey?.currentContext != null && widget.postView?.post.id == null && postId != null) {
showSnackbar(
context,
l10n.postCreatedSuccessfully,
trailingIcon: Icons.remove_red_eye_rounded,
trailingAction: () {
navigateToPost(widget.scaffoldMessengerKey!.currentContext!, postId: postId);
},
customState: widget.scaffoldMessengerKey?.currentState,
);
}
},
icon: Icon(
widget.postView != null ? Icons.edit_rounded : Icons.send_rounded,
Expand Down
9 changes: 6 additions & 3 deletions lib/community/widgets/community_sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ class _CommunitySidebarState extends State<CommunitySidebar> {
child: ListView(
shrinkWrap: true,
children: [
CommonMarkdownBody(
body: communityView.community.description ?? '',
imageMaxWidth: (kSidebarWidthFactor - 0.1) * MediaQuery.of(context).size.width,
Material(
child: CommonMarkdownBody(
body: communityView.community.description ?? '',
imageMaxWidth: (kSidebarWidthFactor - 0.1) * MediaQuery.of(context).size.width,
allowHorizontalTranslation: false,
),
),
const SidebarSectionHeader(value: "Stats"),
Padding(
Expand Down
18 changes: 14 additions & 4 deletions lib/feed/view/feed_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class FeedPage extends StatefulWidget {
this.userId,
this.username,
this.scaffoldStateKey,
this.scaffoldMessengerKey,
});

/// The type of feed to display.
Expand Down Expand Up @@ -84,6 +85,9 @@ class FeedPage extends StatefulWidget {
/// The scaffold key which holds the drawer
final GlobalKey<ScaffoldState>? scaffoldStateKey;

/// The messenger key back to the main Thunder page
final GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey;

@override
State<FeedPage> createState() => _FeedPageState();
}
Expand Down Expand Up @@ -127,7 +131,7 @@ class _FeedPageState extends State<FeedPage> with AutomaticKeepAliveClientMixin<

return BlocProvider.value(
value: bloc,
child: FeedView(scaffoldStateKey: widget.scaffoldStateKey),
child: FeedView(scaffoldStateKey: widget.scaffoldStateKey, scaffoldMessengerKey: widget.scaffoldMessengerKey),
);
}

Expand All @@ -143,17 +147,20 @@ class _FeedPageState extends State<FeedPage> with AutomaticKeepAliveClientMixin<
username: widget.username,
reset: true,
)),
child: FeedView(scaffoldStateKey: widget.scaffoldStateKey),
child: FeedView(scaffoldStateKey: widget.scaffoldStateKey, scaffoldMessengerKey: widget.scaffoldMessengerKey),
);
}
}

class FeedView extends StatefulWidget {
const FeedView({super.key, this.scaffoldStateKey});
const FeedView({super.key, this.scaffoldStateKey, this.scaffoldMessengerKey});

/// The scaffold key which holds the drawer
final GlobalKey<ScaffoldState>? scaffoldStateKey;

/// The messenger key back to the main Thunder page
final GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey;

@override
State<FeedView> createState() => _FeedViewState();
}
Expand Down Expand Up @@ -426,7 +433,10 @@ class _FeedViewState extends State<FeedView> {
curve: Curves.easeIn,
child: Container(
margin: const EdgeInsets.all(16),
child: FeedFAB(heroTag: state.communityName),
child: FeedFAB(
heroTag: state.communityName,
scaffoldMessengerKey: widget.scaffoldMessengerKey,
),
),
),
],
Expand Down
6 changes: 5 additions & 1 deletion lib/feed/widgets/feed_fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import 'package:thunder/shared/sort_picker.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';

class FeedFAB extends StatelessWidget {
const FeedFAB({super.key, this.heroTag});
const FeedFAB({super.key, this.heroTag, this.scaffoldMessengerKey});

final String? heroTag;

/// The messenger key back to the main Thunder page
final GlobalKey<ScaffoldMessengerState>? scaffoldMessengerKey;

@override
build(BuildContext context) {
final ThunderState state = context.watch<ThunderBloc>().state;
Expand Down Expand Up @@ -287,6 +290,7 @@ class FeedFAB extends StatelessWidget {
child: CreatePostPage(
communityId: feedBloc.state.communityId,
communityView: feedBloc.state.fullCommunityView?.communityView,
scaffoldMessengerKey: scaffoldMessengerKey,
),
);
},
Expand Down
Loading

0 comments on commit bff523e

Please sign in to comment.