Skip to content

Commit

Permalink
1) Modified some low level widgets to allow more design freedom
Browse files Browse the repository at this point in the history
2) Corrected flutter template files for windows - bug removed..
  • Loading branch information
hkhauke committed Jun 4, 2024
1 parent 9288fd7 commit 063dcea
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 13 deletions.
Binary file modified flutter/ayf_pack/images/ayf-icons.vsdx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ class _AudYoFloPropertyShowState extends State<AudYoFloPropertyShow> {
selLstBe: selLst,
height: 40,
offset: nOpts.selIdx,
numCharsMax: 20,
);

contentWidget = newWidget;
Expand Down
26 changes: 22 additions & 4 deletions flutter/ayf_pack/lib/helpers/ayf_helper_lib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,34 @@ void decodeDeviceChannel(
}
}

String limitString(String txt, int numCharsMax) {
enum ayfShortenTextOption {
AYF_SHORTEN_TEXT_FRONT,
AYF_SHORTEN_TEXT_BACK,
AYF_SHORTEN_TEXT_MIDDLE
}

String limitString(String txt, int numCharsMax,
{ayfShortenTextOption shortenOption =
ayfShortenTextOption.AYF_SHORTEN_TEXT_MIDDLE}) {
String retVal = txt;
int numCharsUse = numCharsMax - 4;
numCharsUse = max(2, numCharsUse);
int numCharsStart = numCharsUse ~/ 2;
switch (shortenOption) {
case ayfShortenTextOption.AYF_SHORTEN_TEXT_FRONT:
numCharsStart = 1;
break;
case ayfShortenTextOption.AYF_SHORTEN_TEXT_BACK:
numCharsStart = numCharsUse;
break;
default:
break;
}
int numCharsStop = numCharsUse - numCharsStart;

if (txt.length > numCharsMax) {
retVal = txt.substring(0, numCharsStart - 1) +
"...." +
txt.substring(txt.length - numCharsStop - 1);
retVal =
"${txt.substring(0, numCharsStart - 1)}....${txt.substring(txt.length - numCharsStop - 1)}";
}

return retVal;
Expand Down
19 changes: 12 additions & 7 deletions flutter/ayf_pack/lib/simple-widgets/ayf_prop_list_combobox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ class AudYoFloPropListComboBoxWidget extends StatelessWidget {
final AyfPropertyReportLevel reportSet;
final bool invalidatePropOnSet;
final double height;
final int numCharsMax = 25;
final int numCharsMax;
final String prefix;
final int offset;
final ayfShortenTextOption textOpt;

/* This combobox can be used to control backend and local
properties. There should always be either selLstBe or
selLstLo. It constructs the combobox with all options and
then waits for a selection.
In reportSet the report type is specified.*/
AudYoFloPropListComboBoxWidget(
const AudYoFloPropListComboBoxWidget(
{this.selLstBe,
this.selLstLo,
this.strLstBe,
Expand All @@ -41,7 +42,9 @@ class AudYoFloPropListComboBoxWidget extends StatelessWidget {
this.invalidatePropOnSet = true,
this.height = 40,
this.prefix = ' ',
this.offset = 0});
this.offset = 0,
this.numCharsMax = 20,
this.textOpt = ayfShortenTextOption.AYF_SHORTEN_TEXT_FRONT});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -119,7 +122,7 @@ class AudYoFloPropListComboBoxWidget extends StatelessWidget {
.map<DropdownMenuItem<AudYoFloPropLstSelEntry>>(
(AudYoFloPropLstSelEntry value) {
String txt = value.txt;
txt = limitString(txt, numCharsMax);
txt = limitString(txt, numCharsMax, shortenOption: textOpt);
txt = prefix + txt;
Widget cW = Text(txt);
if (value.isSel) {
Expand Down Expand Up @@ -171,12 +174,14 @@ class AudYoFloPropListComboBoxWidget extends StatelessWidget {

// We need to propagate the updated property to the
// higher level widget to refresh the property in cache
theBeCache!.triggerSetProperties(cpId, propContents,
theBeCache.triggerSetProperties(cpId, propContents,
report: reportSet,
invalidateProperty: invalidatePropOnSet);
invalidateProperty: invalidatePropOnSet,
offset: offset);
} else if (selLstLo != null) {
applyChangeSelectionList(selLstLo!.selection,
newValue.posi, selLstLo!.decTp);
newValue.posi, selLstLo!.decTp,
offset: offset);
theUiModel!.reportSetProperty(selLstLo!);
}
}
Expand Down
12 changes: 11 additions & 1 deletion flutter/ayf_pack/lib/sub-widgets/ayf_active_textfield.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ class _AudYoFloActiveTextFieldStates extends State<AudYoFloActiveTextField> {
onTap: () {
//myNode.requestFocus();
},
decoration: const InputDecoration(border: OutlineInputBorder()),
decoration: InputDecoration(
// Here I have tested a lot. If the text is too wide, it disappears!
// We can avoid this by re-defining the default EdgeInsets. We need the left border inset however, to look nice.
// isDense: true,
contentPadding: const EdgeInsets.fromLTRB(5, 0, 0, 0),
filled: true,
fillColor: Colors.white,
border: OutlineInputBorder(
gapPadding: 12, borderRadius: BorderRadius.circular(12)),
),
//decoration: const InputDecoration(border: OutlineInputBorder()),
),
onFocusChange: (value) {
if (!value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ target_include_directories(${PLUGIN_NAME} PRIVATE
"${AYF_SDK_PATH}/flutter/project_templates/common"
"${AYF_SDK_PATH}/flutter/project_templates/windows/ayfcorepack"
"${AYF_SDK_PATH}/include/${AYF_PROJECT}/include"
"${CMAKE_CURRENT_SOURCE_DIR}"
)

target_link_directories(${PLUGIN_NAME} PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ target_compile_definitions(${PLUGIN_NAME} PRIVATE "FLUTTER_PLUGIN_IMPL;AYF_PROJE
# Source include directories and library dependencies. Add any plugin-specific
# dependencies here.
target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)

# target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)

Expand All @@ -90,6 +91,7 @@ target_include_directories(${PLUGIN_NAME} PRIVATE
"${AYF_SDK_PATH}/flutter/project_templates/common"
"${AYF_SDK_PATH}/flutter/project_templates/windows/ayfcorepack"
"${AYF_SDK_PATH}/include/${AYF_PROJECT}/include"
"${CMAKE_CURRENT_SOURCE_DIR}"
)

target_link_directories(${PLUGIN_NAME} PRIVATE
Expand Down

0 comments on commit 063dcea

Please sign in to comment.