Skip to content

Commit

Permalink
Merge pull request #1 from 1runeberg/fix-phone-layout
Browse files Browse the repository at this point in the history
Fix phone layout
  • Loading branch information
1runeberg authored Aug 19, 2024
2 parents 5653a76 + db95216 commit 066a275
Show file tree
Hide file tree
Showing 14 changed files with 713 additions and 465 deletions.
11 changes: 5 additions & 6 deletions confichat/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions confichat/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 19 additions & 18 deletions confichat/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions confichat/lib/app_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@
* SPDX-License-Identifier: Apache-2.0
*/

import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:confichat/interfaces.dart';
import 'package:confichat/factories.dart';


typedef CallbackSwitchProvider = Function(AiProvider?);
class AppData {

// Singleton setup
static final AppData _instance = AppData._internal();
static AppData get instance => _instance;
AppData._internal();

late CallbackSwitchProvider callbackSwitchProvider;
AppData._internal() : super() {
callbackSwitchProvider = defaultCallback;
}

// Class vars
static const String appTitle = 'ConfiChat';
Expand All @@ -31,13 +38,16 @@ class AppData {

// Public vars
LlmApi api = LlmApiFactory.create(AiProvider.ollama.name);
bool clearMessagesOnModelSwitch = false;
bool clearMessagesOnModelSwitch = true;
bool filterHistoryByModel = false;
int appScrollDurationInms = 100;
double windowWidth = 1024;
double windowHeight = 1024;
String rootPath = '';

void defaultCallback(AiProvider? provider) {
}

void setProvider(AiProvider provider){

switch (provider) {
Expand All @@ -52,6 +62,22 @@ class AppData {
}
}

UserDeviceType getUserDeviceType(BuildContext context) {
final double deviceWidth = MediaQuery.of(context).size.shortestSide;

if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
return UserDeviceType.desktop;
} else if (Platform.isAndroid || Platform.isIOS) {
if (deviceWidth > 600) {
return UserDeviceType.tablet;
} else {
return UserDeviceType.phone;
}
} else {
return UserDeviceType.desktop;
}
}

}

enum AiProvider {
Expand All @@ -63,6 +89,12 @@ enum AiProvider {
const AiProvider(this.name, this.id);
}

enum UserDeviceType {
desktop,
phone,
tablet
}

class ModelItem {
final String id;
final String name;
Expand Down
2 changes: 1 addition & 1 deletion confichat/lib/interfaces.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ abstract class LlmApi {
List<String> stopSequences = [];

String systemPrompt = '';
String summaryPrompt = 'Create a title or subject heading of our conversation so far in one sentence, with a maximum of 100 characters. Only use alphanumeric characters, spaces, and dashes when appropraite. Do not add a period and do not add any comments, just the title/subject heading as requested.';
String summaryPrompt = 'Create a title or subject heading of our conversation so far in one sentence, with a maximum of 100 characters. Only use alphanumeric characters, spaces, and dashes when appropraite. Do not add a period, slash, colon, and do not add any comments, just the title/subject heading as requested.';

bool isProcessing = false;
String responseData = 'No data';
Expand Down
Loading

0 comments on commit 066a275

Please sign in to comment.