A: Tile Widget, inside a Pivot Item,
itself is a Pivot, with 3 items.
1 Track Image (import, Scroll, Sort and Shuffle)
2. Lyrics (imp/export)
3. Equalizer Control and Setting Load and Save.
1 & 2 create inside a switch-branch
3 is a separate Widget.
B: xml IO test.
__________________
Widget _currentWidget = Container();
int sharedContainerIndex = 0;
void _switchWidget(int thisIndex) {
setState(() {
switch (thisIndex) {
// Track IMAGE
case 0:
_currentWidget = new Container( ... );
break;
// LYRICS
case 1:
_currentWidget = Container(... );
break;
// E Q
case 2:
_currentWidget = new Container( ...);
break;
default:
break;
}
sharedContainerIndex = thisIndex;
});
}
__________________________________
on isPlaying, move out of the view
with AnimatedPositioned, persistent.
__________________________________
AnimatedPositioned(duration: Duration(seconds: 1),
top: isPlaying ? 100 : contextHeight,
right: 50,
child: GestureDetector
(
onTap: scrollToRow,
child: _currentWidget,
) ,
),
_____________________________________
Each Widget can switch to the other 2
by index 0,1, or 2
_____________________________________
btnCallback: () async { _switchWidget(1); }),
_____________________________________________
XML for EQ setting, vs .plist from Swift
_____________________________________________
load .xml
void updateInitialEQSettings() async
{
String appDocUserPath = await userPath();
String filePath = appDocUserPath + "/Music/ltsMusicPlayer/0.xml";
List*double* eqGains = List*double*.filled(11,0);
try {
final file = new File(filePath);
final document = XmlDocument.parse(file.readAsStringSync());
final realNumbers = document.findAllElements('real');
int idx = 0;
if (realNumbers.length == 11)
{
realNumbers.forEach((element) {
double? value = double.parse(element.text);
eqGains[idx] = value; idx++; // no ?? def=0
});
}
Imagedata.setEQState(0, eqGains , 0);
} on Exception catch (e) {
//print(e);
}
}
write xml:
String appDocUserPath = await userPath();
String filePath = appDocUserPath + "/Music/ltsMusicPlayer";
final isExisted = await createFolderIfNotExisted(filePath);
if (isExisted)
{
filePath = filePath + "/" + sname;
//print(filePath);
File file = File(filePath);
final builder = XmlBuilder();
builder.processing('xml', 'version="1.0"');
builder.element('array', nest: () {
builder.element('real', nest: _eqGains[0]);
builder.element('real', nest: _eqGains[1]);
builder.element('real', nest: _eqGains[2]);
builder.element('real', nest: _eqGains[3]);
builder.element('real', nest: _eqGains[4]);
builder.element('real', nest: _eqGains[5]);
builder.element('real', nest: _eqGains[6]);
builder.element('real', nest: _eqGains[7]);
builder.element('real', nest: _eqGains[8]);
builder.element('real', nest: _eqGains[9]);
builder.element('real', nest: _eqGains[10]);
});
final docXml = builder.buildDocument();
final str = docXml.toXmlString(pretty: true, indent: '\t');
file.writeAsString(str);
bandUpdate(); // channel method for AudioManager Update
}
___________________________________
Future*String* userPath() async
{
IO.Directory appDocDir = await getApplicationDocumentsDirectory(); // package path provider
String appDocPath = appDocDir.path;
List*String* comps = appDocPath.split('/');
String userFileP = "/" + comps[1] + "/" + comps[2];
return userFileP;
}
Future*bool* createFolderIfNotExisted(String fullPath) async
{
final IO.Directory thisFolder = IO.Directory(fullPath);
if ( await thisFolder.exists() )
{
return true;
}
else
{
try
{
final IO.Directory strReturn = await thisFolder.create(recursive: true);
return true;
} on Exception catch (e) { print(e); }
}
return false;
}
_______________
Resources
Xcode 12.4
MacOS 11.2.3
AS 4.1.3
Flutter 2.2.0-11.0.pre.199
_______________
Next problem to solve, use Isolate to unblock,
That doTheMetaDataThing(), which blocking UI.