mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 10:38:41 +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/db_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:twonly/src/utils.dart';
|
||||
|
||||
import 'src/app.dart';
|
||||
import 'src/settings/settings_controller.dart';
|
||||
|
|
@ -11,36 +13,36 @@ late DbProvider dbProvider;
|
|||
late ApiProvider apiProvider;
|
||||
|
||||
void main() async {
|
||||
// Set up the SettingsController, which will glue user settings to multiple
|
||||
// Flutter Widgets.
|
||||
final settingsController = SettingsController(SettingsService());
|
||||
|
||||
// Load the user's preferred theme while the splash screen is displayed.
|
||||
// This prevents a sudden theme change when the app is first displayed.
|
||||
await settingsController.loadSettings();
|
||||
|
||||
// Ensure that plugin services are initialized so that `availableCameras()`
|
||||
// can be called before `runApp()`
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
Logger.root.level = Level.ALL; // defaults to Level.INFO
|
||||
Logger.root.level = kReleaseMode ? Level.INFO : Level.ALL;
|
||||
Logger.root.onRecord.listen((record) {
|
||||
debugPrint(
|
||||
'${record.level.name}: twonly:${record.loggerName}: ${record.message}');
|
||||
if (kReleaseMode) {
|
||||
writeLogToFile(record);
|
||||
} else {
|
||||
debugPrint(
|
||||
'${record.level.name}: twonly:${record.loggerName}: ${record.message}');
|
||||
}
|
||||
});
|
||||
|
||||
// Create or open the database
|
||||
dbProvider = DbProvider();
|
||||
// Database is just a file, so this will not block the loading of the app much
|
||||
await dbProvider.ready;
|
||||
|
||||
// Create an option to select different servers.
|
||||
var apiUrl = "ws://api.theconnectapp.de/v-1/";
|
||||
if (true) {
|
||||
var apiUrl = "ws://api.twonly.eu/api/client";
|
||||
var backupApiUrl = "ws://api2.twonly.eu/api/client";
|
||||
if (!kReleaseMode) {
|
||||
// Overwrite the domain in your local network so you can test the app locally
|
||||
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 {
|
||||
// await _HomeState().manager();
|
||||
|
|
@ -48,8 +50,5 @@ void main() async {
|
|||
// 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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
"registerSubmitButton": "Register now!",
|
||||
"newMessageTitle": "New message",
|
||||
"chatsTitle": "Chats",
|
||||
"shareImageTitle": "Share image",
|
||||
"shareImageTitle": "Share with",
|
||||
"shareImageBestFriends": "Best friends",
|
||||
"shareImagedEditorSendImage": "Send",
|
||||
"shareImagedEditorSaveImage": "Save",
|
||||
"shareImagedEditorSavedImage": "Saved",
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
import 'package:gal/gal.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:twonly/main.dart';
|
||||
import 'package:twonly/src/model/contacts_model.dart';
|
||||
import 'package:twonly/src/signal/signal_helper.dart';
|
||||
|
|
@ -127,3 +129,15 @@ Future<Result> createNewUser(String username, String inviteCode) async {
|
|||
|
||||
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),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
alignment:
|
||||
Alignment.centerLeft, // Aligns the container to the left
|
||||
padding: EdgeInsets.all(16.0), // Optional: Add some padding
|
||||
child: Text(
|
||||
'Best friends',
|
||||
style: TextStyle(
|
||||
fontSize: 20, // Set the font size to 20
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 4.0, vertical: 10),
|
||||
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(
|
||||
users: _knownUsers,
|
||||
onChanged: (userId, checkedId) {
|
||||
setState(() {
|
||||
if (checkedId) {
|
||||
_selectedUserIds.add(userId);
|
||||
} else {
|
||||
_selectedUserIds.remove(userId);
|
||||
}
|
||||
});
|
||||
}),
|
||||
const SizedBox(height: 10),
|
||||
// Expanded(
|
||||
// child: UserList(_filteredUsers),
|
||||
// )
|
||||
SizedBox(
|
||||
height: 120,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
FilledButton.icon(
|
||||
icon: Icon(Icons.send),
|
||||
onPressed: () async {
|
||||
print(_selectedUserIds);
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// 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;
|
||||
|
||||
return Column(
|
||||
spacing: 8,
|
||||
children: List.generate((limitedUsers.length + 1) ~/ 2, (rowIndex) {
|
||||
final firstUserIndex = rowIndex * 2;
|
||||
final secondUserIndex = firstUserIndex + 1;
|
||||
|
|
@ -97,11 +136,15 @@ class UserCheckboxList extends StatelessWidget {
|
|||
Expanded(
|
||||
child: UserCheckbox(
|
||||
user: limitedUsers[firstUserIndex], onChanged: onChanged)),
|
||||
if (secondUserIndex < limitedUsers.length)
|
||||
Expanded(
|
||||
child: UserCheckbox(
|
||||
user: limitedUsers[secondUserIndex],
|
||||
onChanged: onChanged)),
|
||||
(secondUserIndex < limitedUsers.length)
|
||||
? Expanded(
|
||||
child: UserCheckbox(
|
||||
user: limitedUsers[secondUserIndex],
|
||||
onChanged: onChanged),
|
||||
)
|
||||
: Expanded(
|
||||
child: Container(),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in a new issue