Skip to content

Commit

Permalink
Merge pull request #4 from ProductLoft/suriya/showInsights
Browse files Browse the repository at this point in the history
Suriya/show insights
  • Loading branch information
subygan authored Mar 24, 2024
2 parents 0774af6 + 94930e7 commit a6c7ca8
Show file tree
Hide file tree
Showing 11 changed files with 344 additions and 91 deletions.
66 changes: 66 additions & 0 deletions .github/01_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and Release macOS App

on:
push:
tags: # Trigger on creating a new tag (e.g., v1.0.0)
- 'v*'

jobs:
build-and-release:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- name: Install Dependencies (if needed)
run: brew install any-dependency

- name: Set up Code Signing
run: |
# Export certificate from Keychain (replace placeholders)
security export -t codesigning -i "Apple Development: Name (ID)" -P "YourPassword" -o development.p12
# Import certificate into Keychain
security import development.p12 -k login.keychain -P "YourPassword" -T /usr/bin/codesign
- name: Build the App
run: |
xcodebuild -workspace YourApp.xcworkspace \
-scheme YourAppScheme \
-configuration Release \
CODE_SIGN_STYLE=Automatic \
CODE_SIGN_IDENTITY="Apple Development: Name (ID)" \
PROVISIONING_PROFILE_SPECIFIER="Provisioning Profile Name" \
archive -archivePath build/YourApp.xcbuild
# Build for macOS, adjust flags/parameters if needed
- name: Prepare Release Artifacts
run: |
# Create a release directory if needed
mkdir -p release
# Copy the app, dSYM file, and any other assets into the release directory
cp -r build/YourApp.xcbuild/Release/YourApp.app release/
cp -r build/YourApp.xcbuild/dSYMs/YourApp.dSYM release/
- name: Create Release on GitHub
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
*Download Links* (Adjust as needed)
* macOS App: [YourApp.zip](URL_TO_ZIP)
draft: false
prerelease: false

- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/YourApp.app.zip # Zip the app if needed
asset_name: YourApp.app.zip
asset_content_type: application/zip
21 changes: 18 additions & 3 deletions lib/const/consts.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@


const DB_PATH = "db/lang.db";
const dbPath = "db/lang.db";

// names of columns


// names of columns for user table
const String userTable = "user";
const String userIdColumn = "id";
const String nameColumn = "name";
const String usernameColumn = "username";
const String emailColumn = "email";
const String cookieColumn = "cookie";
const String cookieColumn = "cookie";

// names of columns for recording table
const String recordingTable = "recording";
const String idColumn = "id";
const String filePathColumn = "filePath";
const String commentColumn = "comment";
const String lengthColumn = "length";
const String timestampColumn = "timestamp";


// consts for network calls
const String baseUrl = "http://127.0.0.1:8000";
const String loginUri = "/auth/login/";
10 changes: 10 additions & 0 deletions lib/const/utils.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import 'package:lang_fe/const/consts.dart';

String getAuthUrl() {
return '$baseUrl$loginUri';
}

String getCurrentTime() {
return DateTime.now().toIso8601String();
}
15 changes: 11 additions & 4 deletions lib/db/db_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import 'package:path_provider/path_provider.dart';
import 'user_models.dart'; // Import your data model
import 'package:lang_fe/const/consts.dart';



// Create and manage database from here. Creation of new models need to be registered here.
//
class DatabaseHelper {
static const _databaseName = DB_PATH;
static const _databaseName = dbPath;
static const _databaseVersion = 1;

Future<Database> get database async {
Expand All @@ -30,5 +28,14 @@ class DatabaseHelper {
$emailColumn text not null
);
''');
}
await db.execute('''
create table $recordingTable (
$idColumn integer primary key autoincrement,
$filePathColumn text not null,
$commentColumn text not null,
$lengthColumn text not null,
$timestampColumn text not null
);
''');
}
}
81 changes: 81 additions & 0 deletions lib/db/recording_models.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import 'package:flutter/foundation.dart';
import 'package:sqflite/sqflite.dart';

import '../const/consts.dart';
import 'db_helper.dart';

class Recording {
int? id;
final String path;
final String comment;
final String length;
final String timestamp;

Recording({
this.id,
required this.path,
required this.comment,
required this.length,
required this.timestamp,
});

Map<String, Object?> toMap() {
var map = <String, Object?>{
idColumn: id,
filePathColumn: path,
commentColumn: comment,
lengthColumn: length,
timestampColumn: timestamp,
};
return map;
}
}

class RecordingProvider {
RecordingProvider();

Future<Recording?> createRecording(
filePath, comment, length, timestamp) async {
Database db = await DatabaseHelper().database;
Recording recording = Recording(
path: filePath,
comment: comment,
length: length,
timestamp: timestamp,
);
print(recording.toMap());
var r = await db.insert(recordingTable, recording.toMap(),
conflictAlgorithm: ConflictAlgorithm.replace);
recording.id = r;
return recording;
}

Future<List<Recording>> getAll() async {
Database db = await DatabaseHelper().database;
List<Map<String, Object?>> maps = await db.query(recordingTable);
List<Recording> recordings = [];
for (var map in maps) {
recordings.add(Recording(
id: map[idColumn] as int,
path: map[filePathColumn] as String,
comment: map[commentColumn] as String,
length: map[lengthColumn] as String,
timestamp: map[timestampColumn] as String,
));
}
return recordings;
}

Future<bool> deleteRecording(int id) async {
Database db = await DatabaseHelper().database;
int r = await db
.delete(recordingTable, where: '$idColumn = ?', whereArgs: [id]);
if (r < 1) {
return false;
}
return true;
}



}
26 changes: 24 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';
import 'dart:io';

import 'package:lang_fe/const/utils.dart';
import 'package:lang_fe/db/user_models.dart';
import 'package:lang_fe/pages/recording_page.dart';
import 'package:http/http.dart' as http;
Expand Down Expand Up @@ -65,6 +66,7 @@ class _WidgetGalleryState extends State<WidgetGallery> {
final _formKey = GlobalKey<FormState>();
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final FocusNode _myFocusNode = FocusNode();

late final searchFieldController = TextEditingController();

Expand Down Expand Up @@ -163,7 +165,7 @@ class _WidgetGalleryState extends State<WidgetGallery> {

try {
final response = await http.post(
Uri.parse('http://127.0.0.1:8000/auth/login/'),
Uri.parse(getAuthUrl()),
body: {
'username': _emailController.text,
'password': _passwordController.text
Expand Down Expand Up @@ -208,6 +210,14 @@ class _WidgetGalleryState extends State<WidgetGallery> {
}
}

@override
void dispose() {
// Dispose of the FocusNode when the widget is removed
_myFocusNode.dispose();
super.dispose();
}


// Handle user login
MacosScaffold getLogin() {
return MacosScaffold(
Expand All @@ -221,6 +231,7 @@ class _WidgetGalleryState extends State<WidgetGallery> {
controller: scrollController,
padding: const EdgeInsets.all(20),
child: Form(

key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
Expand Down Expand Up @@ -251,7 +262,7 @@ class _WidgetGalleryState extends State<WidgetGallery> {
if (_formKey.currentState!.validate()) {
// Navigate the user to the Home page
_login();
setState(() {});
// setState(() {});
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
Expand All @@ -276,6 +287,17 @@ class _WidgetGalleryState extends State<WidgetGallery> {
child: FutureBuilder(
future: checkLoggedIn(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
_myFocusNode.addListener(() {
if (_myFocusNode.hasFocus &&
!_myFocusNode.hasPrimaryFocus &&
FocusManager.instance.primaryFocus!.context!.widget
is! TextFormField) {
if (_formKey.currentState!.validate()) {
// Submit your form
}
}
});

if (snapshot.hasData && snapshot.data == true) {
return FutureBuilder(
future: getMacosWindow(), // Await the result here
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/audio_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class AudioPlayerState extends State<AudioPlayer> {
super.dispose();
}



@override
Widget build(BuildContext context) {
return LayoutBuilder(
Expand Down
36 changes: 23 additions & 13 deletions lib/pages/audio_recorder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:async';

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

import 'platform/audio_recorder_platform.dart';
Expand All @@ -21,12 +22,12 @@ class _RecorderState extends State<Recorder> with AudioRecorderMixin {
late final AudioRecorder _audioRecorder = AudioRecorder();
StreamSubscription<RecordState>? _recordSub;
RecordState _recordState = RecordState.stop;
bool _textBoxIsVisible = false;
StreamSubscription<Amplitude>? _amplitudeSub;
Amplitude? _amplitude;

@override
void initState() {

_recordSub = _audioRecorder.onStateChanged().listen((recordState) {
_updateRecordState(recordState);
});
Expand All @@ -43,7 +44,9 @@ class _RecorderState extends State<Recorder> with AudioRecorderMixin {
Future<void> _start() async {
try {
if (await _audioRecorder.hasPermission()) {
await _audioRecorder.hasPermission()?debugPrint("true"):debugPrint("False");
await _audioRecorder.hasPermission()
? debugPrint("true")
: debugPrint("False");
const encoder = AudioEncoder.aacLc;

if (!await _isEncoderSupported(encoder)) {
Expand Down Expand Up @@ -81,7 +84,7 @@ class _RecorderState extends State<Recorder> with AudioRecorderMixin {

Future<void> _stop() async {
final path = await _audioRecorder.stop();

_textBoxIsVisible = true;
if (path != null) {
widget.onStop(path);

Expand Down Expand Up @@ -132,15 +135,22 @@ class _RecorderState extends State<Recorder> with AudioRecorderMixin {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildRecordStopControl(),
const SizedBox(width: 20),
_buildPauseResumeControl(),
const SizedBox(width: 20),
_buildText(),
],
);
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildRecordStopControl(),
// if (_textBoxIsVisible) const Padding(
// padding: EdgeInsets.all(8.0),
// child: MacosTextField(
// placeholder: "Enter your text here",
// maxLines: 1,
// ),
// ),
const SizedBox(width: 20),
_buildPauseResumeControl(),
const SizedBox(width: 20),
_buildText(),
],
);
}

@override
Expand Down Expand Up @@ -242,4 +252,4 @@ class _RecorderState extends State<Recorder> with AudioRecorderMixin {
setState(() => _recordDuration++);
});
}
}
}
Empty file added lib/pages/insights.dart
Empty file.
Loading

0 comments on commit a6c7ca8

Please sign in to comment.