-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Manage models
- Loading branch information
Showing
22 changed files
with
714 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: "Olpaka 0.3: Models Galore" | ||
date: 2024-05-06 11:40:00 +0100 | ||
categories: [ releases ] | ||
gallery: | ||
- url: /assets/images/0.3_models_galore_1.webp | ||
image_path: /assets/images/0.3_models_galore_1.webp | ||
title: "New tab in the home screen" | ||
- url: /assets/images/0.3_models_galore_2.webp | ||
image_path: /assets/images/0.3_models_galore_2.webp | ||
title: "Dialog to input the model name" | ||
- url: /assets/images/0.3_models_galore_3.webp | ||
image_path: /assets/images/0.3_models_galore_3.webp | ||
title: "Downloading state for the model" | ||
--- | ||
|
||
Howdy! After some tinkering and encountering a few hiccups with | ||
[DIO HttpClient and streaming API calls](https://github.com/cfug/dio/issues/1279), I'm excited to | ||
unveil a new tab on the home screen: the Models management tab. | ||
|
||
While implementing this feature, I've realized there are a few areas I need to focus on: | ||
|
||
- Finding a workaround for the HTTP client issue; | ||
- Enhancing my understanding | ||
of [Ephemeral vs App state management](https://docs.flutter.dev/data-and-backend/state-mgmt/ephemeral-vs-app); | ||
- Deciding whether to keep or revamp the onboarding process; | ||
- Add analytics to understand user's behaviour (before it's too late :P); | ||
|
||
Despite the challenges, this version has been a valuable learning experience in Flutter, web HTTP | ||
calls, and more. | ||
|
||
My current goal isn't perfection; it's about adding functionality and gaining insights to eventually | ||
deliver a stable and scalable 1.0 version. | ||
|
||
{% include gallery caption="Onboarding screenshots from the app" %} | ||
|
||
Ready to give it a spin? Check out the "Olpaka web app" link above! 😊 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
import 'package:get_it/get_it.dart'; | ||
import 'package:olpaka/home/view_model.dart'; | ||
|
||
registerHome(){ | ||
final l = GetIt.instance; | ||
l.registerFactory(() => HomeViewModel()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get_it/get_it.dart'; | ||
import 'package:olpaka/chat/view.dart'; | ||
import 'package:olpaka/generated/l10n.dart'; | ||
import 'package:olpaka/home/view_model.dart'; | ||
import 'package:olpaka/models/view.dart'; | ||
import 'package:stacked/stacked.dart'; | ||
|
||
class HomeView extends StatelessWidget { | ||
final HomeTab tab; | ||
|
||
const HomeView({super.key, this.tab = HomeTab.chat}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ViewModelBuilder<HomeViewModel>.reactive( | ||
viewModelBuilder: () => GetIt.I.get(), | ||
onViewModelReady: (viewModel) { | ||
viewModel.events.listen((event) { | ||
switch (event) {} | ||
}); | ||
viewModel.onCreate(tab); | ||
}, | ||
builder: (context, viewModel, child) { | ||
final content = switch(viewModel.selectedItem){ | ||
0 => const ChatScreen(), | ||
1 => ModelsScreen(), | ||
int() => throw UnimplementedError(), | ||
}; | ||
return Row( | ||
children: [ | ||
NavigationRail( | ||
groupAlignment: 0.0, | ||
selectedIndex: viewModel.selectedItem, | ||
labelType: NavigationRailLabelType.all, | ||
onDestinationSelected: (index) => viewModel.onItemTapped(index), | ||
destinations: <NavigationRailDestination>[ | ||
NavigationRailDestination( | ||
icon: const Icon(Icons.chat), | ||
selectedIcon: const Icon(Icons.chat_outlined), | ||
label: Text(S.current.home_tab_name_chat), | ||
), | ||
NavigationRailDestination( | ||
icon: const Icon(Icons.auto_awesome_outlined), | ||
selectedIcon: const Icon(Icons.auto_awesome), | ||
label: Text(S.current.home_tab_name_models), | ||
), | ||
], | ||
), | ||
const VerticalDivider(thickness: 1, width: 1), | ||
Expanded(child: content) | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
|
||
class HomeViewModel with ChangeNotifier { | ||
|
||
final _events = StreamController<HomeEvent>.broadcast(); | ||
|
||
Stream<HomeEvent> get events => | ||
_events.stream.map((val) { | ||
return val; | ||
}); | ||
|
||
HomeViewModel(); | ||
|
||
int selectedItem = 0; | ||
|
||
onCreate(HomeTab tab) async { | ||
selectedItem = switch(tab){ | ||
HomeTab.chat => 0, | ||
HomeTab.models => 1, | ||
HomeTab.settings => 2, | ||
}; | ||
notifyListeners(); | ||
} | ||
|
||
onItemTapped(int index) async { | ||
selectedItem = index; | ||
notifyListeners(); | ||
} | ||
} | ||
|
||
sealed class HomeEvent {} | ||
|
||
|
||
enum HomeTab { | ||
chat, | ||
models, | ||
settings | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
import 'package:get_it/get_it.dart'; | ||
import 'package:olpaka/models/view_model.dart'; | ||
|
||
registerModels() { | ||
final l = GetIt.instance; | ||
l.registerFactory(() => ModelsViewModel(l.get())); | ||
} |
Oops, something went wrong.