Skip to content

Commit

Permalink
reply button added, auth continuing
Browse files Browse the repository at this point in the history
  • Loading branch information
yukiterunamaana committed May 28, 2024
1 parent 969d251 commit 32b38fd
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 126 deletions.
43 changes: 22 additions & 21 deletions lib/buttons/reply_button.dart
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
import 'package:flutter/material.dart';
import 'package:mastodon_api/mastodon_api.dart';

import '../widgets/post_creator.dart';

class ReplyButton extends StatelessWidget {
final MastodonApi mastodon;
final String statusId;

ReplyButton({super.key, required this.mastodon, required this.statusId});
//
// @override
// Widget build(BuildContext context) {
// // TODO: implement build
// throw UnimplementedError();
// }

@override
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
return IconButton(
icon: Icon(Icons.reply),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
print(statusId);
return ComposeStatusWidget(
inReplyToId: statusId,
);
},
);
},
);
}

// @override
// Widget build(BuildContext context) {
// return IconButton(
// icon: Icon(Icons.reply),
// onPressed: () {
// showModalBottomSheet(
// context: context,
// builder: (BuildContext context) {
// return null;
// // return NewPostWidget(
// // mastodon: mastodon,
// // inReplyToId: statusId,
// // );
// },
// );
// },
// );
// }
}
3 changes: 2 additions & 1 deletion lib/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import 'instance_settings.dart';
import 'key.dart';

Color itemColor = Colors.black;
Color? selectedItemColor = Colors.amber;
Color? blobColor1 = Colors.amber;
Color? blobColor2 = Colors.amber;
Color? activatedReactionColor = Colors.red;
Color bgColor = Colors.amber;

Expand Down
138 changes: 69 additions & 69 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'myapp.dart';
import 'package:mastodon_oauth2/mastodon_oauth2.dart';
//import 'package:mastodon_api/mastodon_api.dart';

// void main() => runApp(const SignupPage()); // MyApp());
// void main() => runApp(const MyApp()); //SignupPage());
// //todo ASK ABOUT NOTIFICATIONS PROBLEM
// //todo ASK ABOUT USER PAGE PROBLEM

Expand Down Expand Up @@ -132,72 +132,72 @@ class _ExampleState extends State<Example> {
),
);
}

// import 'package:aadj/env.dart';
// import 'package:aadj/instance_settings.dart';
// import 'package:flutter/material.dart';
// import 'widgets/auth.dart';
// import 'myapp.dart';
// import 'package:mastodon_oauth2/mastodon_oauth2.dart';
//
// // void main() => runApp(const SignupPage()); // MyApp());
// // //todo ASK ABOUT NOTIFICATIONS PROBLEM
// // //todo ASK ABOUT USER PAGE PROBLEM
//
// void main() {
// runApp(const MaterialApp(home: Example()));
// }
//
// class Example extends StatefulWidget {
// const Example({Key? key}) : super(key: key);
//
// @override
// State<Example> createState() => _ExampleState();
// }
//
// class _ExampleState extends State<Example> {
// String? _accessToken;
// String? _refreshToken;
//
// @override
// Widget build(BuildContext context) => Scaffold(
// body: Center(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Text('Access Token: $_accessToken'),
// ElevatedButton(
// onPressed: () async {
// final oauth2 = MastodonOAuth2Client(
// // Specify mastodon instance like "mastodon.social"
// instance: instance,
// clientId: Env.clientKey,
// clientSecret: Env.clientSecret,
//
// // Replace redirect url as you need.
// redirectUri: 'aadj://callback',
// customUriScheme: 'http://localhost:8080',
// );
//
// final response = await oauth2.executeAuthCodeFlow(
// scopes: [
// Scope.read,
// Scope.write,
// Scope.follow,
// Scope.push,
// ],
// );
//
// super.setState(() {
// _accessToken = response.accessToken;
// print(_accessToken);
// });
// },
// child: const Text('Push!'),
// )
// ],
// ),
// ),
// );
// }
// // import 'package:aadj/env.dart';
// // import 'package:aadj/instance_settings.dart';
// // import 'package:flutter/material.dart';
// // import 'widgets/auth.dart';
// // import 'myapp.dart';
// // import 'package:mastodon_oauth2/mastodon_oauth2.dart';
// //
// // // void main() => runApp(const SignupPage()); // MyApp());
// // // //todo ASK ABOUT NOTIFICATIONS PROBLEM
// // // //todo ASK ABOUT USER PAGE PROBLEM
// //
// // void main() {
// // runApp(const MaterialApp(home: Example()));
// // }
// //
// // class Example extends StatefulWidget {
// // const Example({Key? key}) : super(key: key);
// //
// // @override
// // State<Example> createState() => _ExampleState();
// // }
// //
// // class _ExampleState extends State<Example> {
// // String? _accessToken;
// // String? _refreshToken;
// //
// // @override
// // Widget build(BuildContext context) => Scaffold(
// // body: Center(
// // child: Column(
// // mainAxisAlignment: MainAxisAlignment.center,
// // crossAxisAlignment: CrossAxisAlignment.center,
// // children: [
// // Text('Access Token: $_accessToken'),
// // ElevatedButton(
// // onPressed: () async {
// // final oauth2 = MastodonOAuth2Client(
// // // Specify mastodon instance like "mastodon.social"
// // instance: instance,
// // clientId: Env.clientKey,
// // clientSecret: Env.clientSecret,
// //
// // // Replace redirect url as you need.
// // redirectUri: 'aadj://callback',
// // customUriScheme: 'http://localhost:8080',
// // );
// //
// // final response = await oauth2.executeAuthCodeFlow(
// // scopes: [
// // Scope.read,
// // Scope.write,
// // Scope.follow,
// // Scope.push,
// // ],
// // );
// //
// // super.setState(() {
// // _accessToken = response.accessToken;
// // print(_accessToken);
// // });
// // },
// // child: const Text('Push!'),
// // )
// // ],
// // ),
// // ),
// // );
// // }
8 changes: 4 additions & 4 deletions lib/widgets/bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ class _AppBottomBarState extends State<AppBottomBar> {
icon: Icon(Icons.home, color: itemColor),
activeIcon: Icon(
Icons.home,
color: selectedItemColor,
color: blobColor1,
),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.search, color: itemColor),
activeIcon: Icon(
Icons.search,
color: selectedItemColor,
color: blobColor1,
),
label: 'Search',
),
Expand All @@ -93,15 +93,15 @@ class _AppBottomBarState extends State<AppBottomBar> {
icon: Icon(Icons.notifications, color: itemColor),
activeIcon: Icon(
Icons.notifications,
color: selectedItemColor,
color: blobColor1,
),
label: 'Notifications',
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle, color: itemColor),
activeIcon: Icon(
Icons.account_circle,
color: selectedItemColor,
color: blobColor1,
),
label: 'Account',
),
Expand Down
58 changes: 32 additions & 26 deletions lib/widgets/post_bottom_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,22 @@ import 'package:aadj/buttons/reply_button.dart';
import 'package:flutter/material.dart';

class PostBottomBar extends StatefulWidget {

final String statusId;
final bool? isReblogged;
final bool? isFavourited; //certified Bri'ish moment
final bool? isBookmarked;
const PostBottomBar({

super.key,

required this.statusId, required this.isReblogged, required this.isFavourited, required this.isBookmarked,
required this.statusId,
required this.isReblogged,
required this.isFavourited,
required this.isBookmarked,
});


@override

_PostBottomBarState createState() => _PostBottomBarState();
}


class _PostBottomBarState extends State<PostBottomBar> {
@override
Widget build(BuildContext context) {
Expand All @@ -39,24 +36,33 @@ class _PostBottomBarState extends State<PostBottomBar> {
// }
// });
// },
return Row(
children: [
//ReplyButton(mastodon: mstdn, statusId: widget.statusId),
ReblogButton(mastodon: mstdn, statusId: widget.statusId, isReblogged: widget.isReblogged),
FavoriteButton(mastodon: mstdn, statusId: widget.statusId, isFavourited: widget.isFavourited),
BookmarkButton(mastodon: mstdn, statusId: widget.statusId, isBookmarked: widget.isBookmarked),
//todo additional menu
const Icon(Icons.menu_rounded),
],
// Icon(
// _isReacted ? Icons.favorite : Icons.favorite_border,
// color: _isReacted ? activatedReactionColor : null,
// ),
//
// Icon(
// _isReacted ? Icons.repeat : Icons.repeat_outlined,
// color: _isReacted ? activatedReactionColor : null,
// ),
return Row(
children: [
ReplyButton(mastodon: mstdn, statusId: widget.statusId),
ReblogButton(
mastodon: mstdn,
statusId: widget.statusId,
isReblogged: widget.isReblogged),
FavoriteButton(
mastodon: mstdn,
statusId: widget.statusId,
isFavourited: widget.isFavourited),
BookmarkButton(
mastodon: mstdn,
statusId: widget.statusId,
isBookmarked: widget.isBookmarked),
//todo additional menu
const Icon(Icons.menu_rounded),
],
// Icon(
// _isReacted ? Icons.favorite : Icons.favorite_border,
// color: _isReacted ? activatedReactionColor : null,
// ),
//
// Icon(
// _isReacted ? Icons.repeat : Icons.repeat_outlined,
// color: _isReacted ? activatedReactionColor : null,
// ),
);
}
}
}
15 changes: 10 additions & 5 deletions lib/widgets/post_creator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import 'package:mastodon_api/mastodon_api.dart';
//import 'emoji_keyboard.dart';

class ComposeStatusWidget extends StatefulWidget {
final String inReplyToId;

ComposeStatusWidget({super.key, this.inReplyToId = ''});

@override
_ComposeStatusWidgetState createState() => _ComposeStatusWidgetState();
}
Expand Down Expand Up @@ -90,8 +94,9 @@ class _ComposeStatusWidgetState extends State<ComposeStatusWidget> {
child: const Text('Publish'),
onPressed: () async {
try {
final response = await mstdn.v1.statuses
.createStatus(text: _statusController.text);
final response = await mstdn.v1.statuses.createStatus(
text: _statusController.text,
inReplyToStatusId: widget.inReplyToId);

if (response.status.code == 200) {
ScaffoldMessenger.of(context).showSnackBar(
Expand Down Expand Up @@ -127,9 +132,9 @@ class _ComposeStatusWidgetState extends State<ComposeStatusWidget> {
print(e.body);
print(e);
}
// Create a new status with the selected options
final status = mstdn.v1.statuses
.createStatus(text: _statusController.text);
// // Create a new status with the selected options
// final status = mstdn.v1.statuses
// .createStatus(text: _statusController.text);
}),
Text('500' /*remainingCharacters.toString()*/),
],
Expand Down

0 comments on commit 32b38fd

Please sign in to comment.