mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 12:28:40 +00:00
add send button
This commit is contained in:
parent
a499f5c635
commit
52ee97c932
4 changed files with 102 additions and 45 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:twonly/src/providers/api_provider.dart';
|
import 'package:twonly/src/providers/api_provider.dart';
|
||||||
import 'package:twonly/src/providers/db_provider.dart';
|
import 'package:twonly/src/providers/db_provider.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:twonly/src/utils.dart';
|
||||||
|
|
||||||
import 'src/app.dart';
|
import 'src/app.dart';
|
||||||
import 'src/settings/settings_controller.dart';
|
import 'src/settings/settings_controller.dart';
|
||||||
|
|
@ -11,36 +13,36 @@ late DbProvider dbProvider;
|
||||||
late ApiProvider apiProvider;
|
late ApiProvider apiProvider;
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
// Set up the SettingsController, which will glue user settings to multiple
|
|
||||||
// Flutter Widgets.
|
|
||||||
final settingsController = SettingsController(SettingsService());
|
final settingsController = SettingsController(SettingsService());
|
||||||
|
|
||||||
// Load the user's preferred theme while the splash screen is displayed.
|
// Load the user's preferred theme while the splash screen is displayed.
|
||||||
// This prevents a sudden theme change when the app is first displayed.
|
// This prevents a sudden theme change when the app is first displayed.
|
||||||
await settingsController.loadSettings();
|
await settingsController.loadSettings();
|
||||||
|
|
||||||
// Ensure that plugin services are initialized so that `availableCameras()`
|
|
||||||
// can be called before `runApp()`
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
Logger.root.level = Level.ALL; // defaults to Level.INFO
|
Logger.root.level = kReleaseMode ? Level.INFO : Level.ALL;
|
||||||
Logger.root.onRecord.listen((record) {
|
Logger.root.onRecord.listen((record) {
|
||||||
debugPrint(
|
if (kReleaseMode) {
|
||||||
'${record.level.name}: twonly:${record.loggerName}: ${record.message}');
|
writeLogToFile(record);
|
||||||
|
} else {
|
||||||
|
debugPrint(
|
||||||
|
'${record.level.name}: twonly:${record.loggerName}: ${record.message}');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create or open the database
|
|
||||||
dbProvider = DbProvider();
|
dbProvider = DbProvider();
|
||||||
|
// Database is just a file, so this will not block the loading of the app much
|
||||||
await dbProvider.ready;
|
await dbProvider.ready;
|
||||||
|
|
||||||
// Create an option to select different servers.
|
var apiUrl = "ws://api.twonly.eu/api/client";
|
||||||
var apiUrl = "ws://api.theconnectapp.de/v-1/";
|
var backupApiUrl = "ws://api2.twonly.eu/api/client";
|
||||||
if (true) {
|
if (!kReleaseMode) {
|
||||||
// Overwrite the domain in your local network so you can test the app locally
|
// Overwrite the domain in your local network so you can test the app locally
|
||||||
apiUrl = "ws://10.99.0.6:3030/api/client";
|
apiUrl = "ws://10.99.0.6:3030/api/client";
|
||||||
}
|
}
|
||||||
|
|
||||||
apiProvider = ApiProvider(apiUrl: apiUrl, backupApiUrl: null);
|
apiProvider = ApiProvider(apiUrl: apiUrl, backupApiUrl: backupApiUrl);
|
||||||
|
|
||||||
// Workmanager.executeTask((task, inputData) async {
|
// Workmanager.executeTask((task, inputData) async {
|
||||||
// await _HomeState().manager();
|
// await _HomeState().manager();
|
||||||
|
|
@ -48,8 +50,5 @@ void main() async {
|
||||||
// return true;
|
// return true;
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// Run the app and pass in the SettingsController. The app listens to the
|
|
||||||
// SettingsController for changes, then passes it further down to the
|
|
||||||
// SettingsView.
|
|
||||||
runApp(MyApp(settingsController: settingsController));
|
runApp(MyApp(settingsController: settingsController));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
"registerSubmitButton": "Register now!",
|
"registerSubmitButton": "Register now!",
|
||||||
"newMessageTitle": "New message",
|
"newMessageTitle": "New message",
|
||||||
"chatsTitle": "Chats",
|
"chatsTitle": "Chats",
|
||||||
"shareImageTitle": "Share image",
|
"shareImageTitle": "Share with",
|
||||||
|
"shareImageBestFriends": "Best friends",
|
||||||
"shareImagedEditorSendImage": "Send",
|
"shareImagedEditorSendImage": "Send",
|
||||||
"shareImagedEditorSaveImage": "Save",
|
"shareImagedEditorSaveImage": "Save",
|
||||||
"shareImagedEditorSavedImage": "Saved",
|
"shareImagedEditorSavedImage": "Saved",
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:gal/gal.dart';
|
import 'package:gal/gal.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:twonly/main.dart';
|
import 'package:twonly/main.dart';
|
||||||
import 'package:twonly/src/model/contacts_model.dart';
|
import 'package:twonly/src/model/contacts_model.dart';
|
||||||
import 'package:twonly/src/signal/signal_helper.dart';
|
import 'package:twonly/src/signal/signal_helper.dart';
|
||||||
|
|
@ -127,3 +129,15 @@ Future<Result> createNewUser(String username, String inviteCode) async {
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> writeLogToFile(LogRecord record) async {
|
||||||
|
final directory = await getApplicationDocumentsDirectory();
|
||||||
|
final logFile = File('${directory.path}/app.log');
|
||||||
|
|
||||||
|
// Prepare the log message
|
||||||
|
final logMessage =
|
||||||
|
'${record.level.name}: ${record.loggerName}: ${record.message}\n';
|
||||||
|
|
||||||
|
// Append the log message to the file
|
||||||
|
await logFile.writeAsString(logMessage, mode: FileMode.append);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,32 +41,70 @@ class _ShareImageView extends State<ShareImageView> {
|
||||||
padding: EdgeInsets.only(bottom: 20, left: 10, top: 20, right: 10),
|
padding: EdgeInsets.only(bottom: 20, left: 10, top: 20, right: 10),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Expanded(
|
||||||
alignment:
|
child: ListView(
|
||||||
Alignment.centerLeft, // Aligns the container to the left
|
children: [
|
||||||
padding: EdgeInsets.all(16.0), // Optional: Add some padding
|
Container(
|
||||||
child: Text(
|
alignment: Alignment.centerLeft,
|
||||||
'Best friends',
|
padding:
|
||||||
style: TextStyle(
|
EdgeInsets.symmetric(horizontal: 4.0, vertical: 10),
|
||||||
fontSize: 20, // Set the font size to 20
|
child: Text(
|
||||||
),
|
AppLocalizations.of(context)!.shareImageBestFriends,
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
UserCheckboxList(
|
||||||
|
users: _knownUsers,
|
||||||
|
onChanged: (userId, checkedId) {
|
||||||
|
setState(() {
|
||||||
|
if (checkedId) {
|
||||||
|
_selectedUserIds.add(userId);
|
||||||
|
} else {
|
||||||
|
_selectedUserIds.remove(userId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
// Expanded(
|
||||||
|
// child: UserList(_filteredUsers),
|
||||||
|
// )
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
UserCheckboxList(
|
SizedBox(
|
||||||
users: _knownUsers,
|
height: 120,
|
||||||
onChanged: (userId, checkedId) {
|
child: Padding(
|
||||||
setState(() {
|
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||||
if (checkedId) {
|
child: Row(
|
||||||
_selectedUserIds.add(userId);
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
} else {
|
children: [
|
||||||
_selectedUserIds.remove(userId);
|
FilledButton.icon(
|
||||||
}
|
icon: Icon(Icons.send),
|
||||||
});
|
onPressed: () async {
|
||||||
}),
|
print(_selectedUserIds);
|
||||||
const SizedBox(height: 10),
|
// Navigator.push(
|
||||||
// Expanded(
|
// context,
|
||||||
// child: UserList(_filteredUsers),
|
// MaterialPageRoute(
|
||||||
// )
|
// builder: (context) =>
|
||||||
|
// ShareImageView(image: widget.image)),
|
||||||
|
// );
|
||||||
|
},
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: WidgetStateProperty.all<EdgeInsets>(
|
||||||
|
EdgeInsets.symmetric(vertical: 10, horizontal: 30),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
label: Text(
|
||||||
|
AppLocalizations.of(context)!
|
||||||
|
.shareImagedEditorSendImage,
|
||||||
|
style: TextStyle(fontSize: 17),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -87,6 +125,7 @@ class UserCheckboxList extends StatelessWidget {
|
||||||
final limitedUsers = users.length > 8 ? users.sublist(0, 8) : users;
|
final limitedUsers = users.length > 8 ? users.sublist(0, 8) : users;
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
|
spacing: 8,
|
||||||
children: List.generate((limitedUsers.length + 1) ~/ 2, (rowIndex) {
|
children: List.generate((limitedUsers.length + 1) ~/ 2, (rowIndex) {
|
||||||
final firstUserIndex = rowIndex * 2;
|
final firstUserIndex = rowIndex * 2;
|
||||||
final secondUserIndex = firstUserIndex + 1;
|
final secondUserIndex = firstUserIndex + 1;
|
||||||
|
|
@ -97,11 +136,15 @@ class UserCheckboxList extends StatelessWidget {
|
||||||
Expanded(
|
Expanded(
|
||||||
child: UserCheckbox(
|
child: UserCheckbox(
|
||||||
user: limitedUsers[firstUserIndex], onChanged: onChanged)),
|
user: limitedUsers[firstUserIndex], onChanged: onChanged)),
|
||||||
if (secondUserIndex < limitedUsers.length)
|
(secondUserIndex < limitedUsers.length)
|
||||||
Expanded(
|
? Expanded(
|
||||||
child: UserCheckbox(
|
child: UserCheckbox(
|
||||||
user: limitedUsers[secondUserIndex],
|
user: limitedUsers[secondUserIndex],
|
||||||
onChanged: onChanged)),
|
onChanged: onChanged),
|
||||||
|
)
|
||||||
|
: Expanded(
|
||||||
|
child: Container(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue